GetTickCount function

Leonid picture Leonid · Aug 10, 2010 · Viewed 27k times · Source

I have a question regarding GetTickCount function, I have two calls to this function in my code with several commands between them and the function in both calls returns same count. i.e.

var1 = GetTickCount();
code
:
:
var2 = GetTickCount();

var1 and var2 has same values in it.

can someone help?

Answer

Jon Skeet picture Jon Skeet · Aug 10, 2010

Assuming this is the Windows GetTickCount call, that's entirely reasonable:

The resolution of the GetTickCount function is limited to the resolution of the system timer, which is typically in the range of 10 milliseconds to 16 milliseconds.

Note that it's only measuring milliseconds to start with - and you can do an awful lot in a millisecond these days.

The docs go on to say:

If you need a higher resolution timer, use a multimedia timer or a high-resolution timer.

Perhaps QueryPerformanceCounter would be more appropriate?