高精度计时

LARGE_INTEGER nKeyStart; //开始时间
LARGE_INTEGER nKeyEnd;  //结束时间
LARGE_INTEGER nSysFreq;  //系统频率
double diff;    //时间差 (nKeyEnd.QuadPart - nKeyStart.QuadPart);


 //计时开始
QueryPerformanceCounter(&nKeyStart);


DO SOMETHING


//计时结束
 QueryPerformanceCounter(&nKeyEnd);


//计算
 QueryPerformanceFrequency(&nSysFreq);
 diff = nKeyEnd.QuadPart - nKeyStart.QuadPart;
 totalConTime = 1000*diff/nSysFreq.QuadPart;  //毫秒


 

你可能感兴趣的:(c++)