void timer()
{
SetThreadAffinityMask(GetCurrentThread(), 1); //choose core
LARGE_INTEGER start, end;
LARGE_INTEGER freq;
double result;
//timeConsuming();
QueryPerformanceFrequency(&freq);
QueryPerformanceCounter(&start);//start
running(); //running
QueryPerformanceCounter(&end); //end
result=(end.QuadPart - start.QuadPart)/(double)freq.QuadPart;
std::cout<<"start.QuadPart = "<<start.QuadPart<<std::endl; //output start
std::cout<<"end.QuadPart = "<<end.QuadPart<<std::endl; //output end
std::cout<<"consume value = end.QuadPart - start.QuadPart = "<<(end.QuadPart - start.QuadPart)<<std::endl;
cout<<"frequency= "<<freq.QuadPart<<"Hz "<<"("<<(double)freq.QuadPart/1024.0/1024.0<<"GHz)"<<endl;
std::cout<<"Time consumed:= "<<result<<"(s)"<<std::endl; //output consumed time
}
备注:把需要计算的程序代码段放在 runing() 函数中