Can someone decrypt whether timeGetTime () or QueryPerformanceCounter / QueryPerformanceFrequency has lower overhead or / or accuracy?

The idea is that timeGetTime () is used quite often in an existing project (for Windows purposes).

milliseconds = timeGetTime();

Now it can be replaced by

double tmp = (double) lpPerformanceCount.QuadPart/ lpFrequency.QuadPart; 
milliseconds = rint(tmp * 1000);

with lpPerformanceCount.QuadPart and lpFrequency.QuadPart are taken from using a single call to QueryPerformanceCounter () and QueryPerformanceFrequency ().

I know that the internal environment of Windows is a kind of voodoo, but can someone decipher which of the two is more accurate and / or has more overhead?

I suspect accuracy may be the same, but QueryPerformanceCounter may have less overhead. But I do not have hard data to back it up.

Of course, I will not be surprised if it is the other way around.

, , .

0
5

timeGetTime() , BeginPeriod. , . QueryPerformanceCounter , . , .

, QPC, , . , , . , . QPC.

+2

: QueryPerformanceCounter . CPU CPU, , . . MSDN.

+1

QPC. timeGetTime 1-10 ( 1 ), QPC .

. QPC . , , , , , . , , .

. , .

+1

QueryPerformanceCounter . QueryPerformanceFrequency, , . . . . . , QueryPerformanceCounter .

accuracy granularity. QueryPerformanceCounter , timeGetTime .

However, the fastest source GetSystemTimeAsFileTimethat returns a time value in units of 100 ns. But its graininess is not 100 ns. Its granularity depends on the result of timeGetDevCaps and the setting of timeBeginPeriod . Correct installation of the latter can lead to a granularity of about 10,000, which corresponds to approximately 1 ms.

I wrote a few details here .

0
source

All Articles