#include <iostream>
#include <windows.h>
using namespace std;
int main()
{
DWORD star_time = GetTickCount();
//此处需要注意如果数值太小则检测不出来
for (int i = 0; i < 100000000; i++)
{
i++;
}
DWORD end_time = GetTickCount();
cout << "这个程序运行时间为:" << (end_time - star_time) << "ms." << endl;
system("pause");
return 0;
}
#include<ctime>
void f_test2()
{
clock_t start, finish;
start = clock();
for (int i = 0; i < 1000000; i++)
{
int s = 0;
}
finish = clock();
cout << "程序执行时间:" << (double)(finish - start)<<"s" << endl;
}