C++记录程序运行时间
2018-02-09 20:11
253 查看
#include <iostream> #include <vector> #include <algorithm> #include <ctime> using namespace std; int main(int argc, char const *argv[]) { clock_t start_time = clock(); for (int i=0; i<100000000; ++i) { ++i; } //clock_t,clock()定义于time.h中,clock()返回从程序运行时刻开始的时钟周期数, //类型为long.CLOCKS_PER_SEC定义了每秒钟包含多少了时钟单元数,因为计算ms,所以*1000。 clock_t end_time = clock(); cout << "Running time is: " << static_cast<double>(end_time-start_time)/CLOCKS_PER_SEC*1000 << "ms" << endl;//输出运行时间。 system("pause"); return 0; }
相关文章推荐
- C++记录程序运行时间
- C++中两种常用的记录程序运行时间的方法的总结
- c++中记录程序运行时间的函数
- c++记录程序运行时间
- C/C++记录程序运行时间的类
- C++记录某段程序的运行时间
- c++记录程序运行时间
- C++ 记录程序运行时间的方法总结
- C++中两种常用的记录程序运行时间的方法的总结
- c++记录程序运行时间
- 用c++实现记录程序运行时间的类
- C++ 记录程序运行时间
- 题目:C++中两种常用的记录程序运行时间的方法的总结
- c++ 记录程序运行时间
- c++中记录程序运行时间的函数
- c++中记录程序运行时间的函数
- C++记录程序运行时间
- C++记录程序运行的时间
- c++记录程序运行时间
- c++ 测试程序运行时间