C++计时函数

参考:

【C/C++】计时函数比较

 

#include <windows.h>
LARGE_INTEGER t1, t2, tc;
QueryPerformanceFrequency(&tc);
QueryPerformanceCounter(&t1);
//do something
QueryPerformanceCounter(&t2);
std::cout << "time:" << ((t2.QuadPart - t1.QuadPart)*1.0 / tc.QuadPart) <<"s"<< std::endl;

 

clock_t t1 = clock();
//do something
clock_t t2 = clock();
double time = (double)(t2 - t1) / CLOCKS_PER_SEC; 

 

posted @ 2018-09-30 09:28  summer91  阅读(1029)  评论(0编辑  收藏  举报