首页 > 技术文章 > VS中计算程序运行时间

wujing-hubei 2016-07-18 17:47 原文

VS中计算程序运行的时间   http://bbs.csdn.net/topics/39068881

  有时候在设计程序完了之后需要计算程序运行的时间。

  这时候可以使用Windows的库函数 GetIickCount(),其头文件为<windows.h>  

#include<iostream>
#include<windows.h>
int main()
{
DWORD start_time=GetTickCount();
{
//此处为被测试代码
}
DWORD end_time=GetTickCount();
cout<<"The run time is:"<<(end_time-start_time)*1.00/1000<<"s!"<<endl;//输出运行时间
return 0;
}

 

 

推荐阅读