用 QueryPerformanceFrequency 与 QueryPerformanceCounter 计时

来源:互联网 发布:win10平板能装ubuntu 编辑:程序博客网 时间:2024/05/10 01:48

 

void main() {   


 LARGE_INTEGER lv;

 // 获取每秒多少CPU Performance Tick
 QueryPerformanceFrequency( &lv );
 double secondsPerTick = lv.QuadPart;

 // 获取CPU运行到现在经过多少Tick

 QueryPerformanceCounter( &lv );
 double timeTick = lv.QuadPart;

 // 计算CPU运行到现在的时间
 
 
  cout <<"秒:"<< timeTick / secondsPerTick << endl;
  cout <<"分:"<< timeTick / secondsPerTick / 60 << endl;
  cout <<"时:"<< timeTick / secondsPerTick / 60 / 60 << endl;

  cout << GetTickCount()<< endl;


}

原创粉丝点击