Windows gotcha #23923234
Typically when writing code in Windows (desktop or mobile), you will encounter a strange bug in the operating system which requires a workaround. This has been occuring since the very first version of Windows and is still happening today. Lately I have been having odd timing problems with my games on some devices and was trying to discover the reason behind it. On OMAP devices (both PPC + SP) the PerformanceCounter doesn’t really exist and it returns a resolution of 1ms. Under the covers it uses the system tick counter which has a resolution of 1 millisecond. This would be reasonable if it worked as expected, but for some reason, querying the performance counter gives stops and starts and will cause games which depend on this to go both too fast and too slow. The solution is to check the timer frequency with QueryPerformanceFrequency() and if it comes back as 1000, then use the GetTickCount() function instead of the PerformanceCounter functions.
Yeah I recently noticed this too… I just stuck with using GetTickCount(). It seems to do the job quite well…. or am I deluding myself?