Skip to content

Instantly share code, notes, and snippets.

@RobinCPC
Last active January 2, 2016 11:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RobinCPC/8296615 to your computer and use it in GitHub Desktop.
Save RobinCPC/8296615 to your computer and use it in GitHub Desktop.
Calculate computing time
//Measuring performance of function more precisively.
// Include necessary file
#include <windows.h>
// Add code to calculate the computing time of function more precsively
LARGE_INTEGER nFreq;
LARGE_INTEGER nBeginTime;
LARGE_INTEGER nEndTime;
double computing_time;
QueryPerformanceFrequency(&nFreq);
QueryPerformanceCounter(&nBeginTime);
// start counting, add the function you want to measure below
// End counting
QueryPerformanceCounter(&nEndTime);
computing_time = (double) (nEndTime.QuadPart - nBeginTime.QuadPart) / (double)nFreq.QuadPart;
CString time_str;
time_str.Format("Comuting Time: %g us", computing_time*1000*1000); // convect double to CString
AfxMessageBox(time_str); // show message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment