Board index » Visual Studio » Measuring time
|
CMElec
|
Measuring time
Visual Studio57
Hello, I am using the following lines of code to measure the time taken by a function in a MFC application(on Windows 2000/Windows XP) and to display the time in milliseconds on the main dialog. DWORD startTime=0; DWORD ElapsedTime=0; DWORD endTime=0; CString dispTime=""; startTime = GetTickCount(); //function is called here ........................... endTime=GetTickCount(); ElapsedTime = endTime - startTime; dispTime.Format("%d ms",ElapsedTime); m_sBerTime = dispTime; UpdateData(FALSE); The problem is that the times measured and displayed vary as much as by more than 100 ms some times. Is this a normal behavior when using GetTickCount() or am I doing something wrong here? Is there some better way to do this to get accurate time in ms? Thanks in advance for any reply. - |
