Last active
January 2, 2016 11:29
-
-
Save RobinCPC/8296615 to your computer and use it in GitHub Desktop.
Calculate computing time
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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