c++测试代码块所需时间(windows)
发布日期:2021-09-25 21:40:43 浏览次数:0 分类:技术文章
#include <iostream>#include <windows.h>using namespace std;int main(){	double run_time = 0.0;		//运行时间	_LARGE_INTEGER time_start;  //起始时间	_LARGE_INTEGER time_over;	//结束时间	_LARGE_INTEGER freq;	double dqFreq;	//计时器频率	QueryPerformanceCounter(&freq);	dqFreq = (double)freq.QuadPart;	QueryPerformanceCounter(&time_start);	//测试for循环时间	for (int i = 0; i < 10000; i++)	{	}	QueryPerformanceCounter(&time_over);	run_time = 1000 * (time_over.QuadPart - time_start.QuadPart) / dqFreq;	cout << run_time << "ms" << endl;		getchar();	return 0;}

 

上一篇:再读Effective C++ 有感
下一篇:Qt实现 文件比较工具