GetTickCount
GetTickCount是一种函数。GetTickCount返回(retrieve)从操作系统启动所经过(elapsed)的毫秒数,它的返回值是DWORD。
需要添加头文件**#include<windows.h>**
例子:
void test()
{
long t1 = GetTickCount64(); //开始时间
for (int i = 0; i < 1000000; i++)
{
int s +=i ;
}
long t2 = GetTickCount64(); //结束时间
cout << "程序执行时间:" << t2 - t1 << endl; //程序运行的时间得到的时间单位为毫秒 /1000为秒
}