1 //计算一段程序运行的时间
2 #include<iostream>
3 #include<time.h>
4 using namespace std;
5 int main()
6 {
7 clock_t startTime,endTime;
8 startTime = clock();//计时开始
9 for (int i = 0; i < 2147483640; i++)
10 {
11 i++;
12 }
13 endTime = clock();//计时结束
14 cout << "The run time is: " <<(double)(endTime - startTime) / CLOCKS_PER_SEC << "s" << endl;
15 system("pause");
16 return 0;
17 }原文:https://www.cnblogs.com/yangxingsha/p/11778574.html