Skip to content

Instantly share code, notes, and snippets.

@binshengliu
Created October 27, 2011 08:23
Show Gist options
  • Save binshengliu/1319050 to your computer and use it in GitHub Desktop.
Save binshengliu/1319050 to your computer and use it in GitHub Desktop.
test running time of code fragment
LARGE_INTEGER BeginTime ;
LARGE_INTEGER EndTime ;
LARGE_INTEGER Frequency ;
QueryPerformanceFrequency(&Frequency);
QueryPerformanceCounter(&BeginTime) ;
//fragment to test
QueryPerformanceCounter(&EndTime) ;
cout.precision(10);
cout << "Begin: " <<(double)BeginTime.QuadPart <<std::endl;
cout << "End: " <<(double)EndTime.QuadPart <<std::endl;
cout << "Precision: " <<(1/(double)Frequency.QuadPart)*1000000<<"us"<<std::endl;
cout << "Time elapsed: " <<( ((EndTime.QuadPart - BeginTime.QuadPart)*1000000)/(double)Frequency.QuadPart)<<"us"<<std::endl;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment