Precision timer

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 = "<


备注:把需要计算的程序代码段放在 runing() 函数中

你可能感兴趣的:(Tips)