I have come across the following example code when I tried to find example usage of this function supplied by WinAPI:
Code:
__int64 freq, start, end, diff;
// start
QueryPerformanceFrequency((LARGE_INTEGER*)&freq);
QueryPerformanceCounter((LARGE_INTEGER*)&start);
// code to measure
Sleep(1234);
// end
QueryPerformanceCounter((LARGE_INTEGER*)&end);
diff = ((end - start) * 1000) / freq;
unsigned int milliseconds = (unsigned int)(diff & 0xffffffff);
printf("It took %u ms\n", milliseconds);
For the line highlighted in red, as I stepped through the debugger, it appears diff is in the order of milliseconds, but I have trouble finding documentation saying that it is so. Can someone confirm that this is indeed the case?
Thanks.