Jump to content
  • Advertisement
Sign in to follow this  
Aerodactyl55

QueryPerformanceFrequency/QueryPerformanceCounter

This topic is 2460 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

MSDN says that the frequency cannot change while the system is running, but i have seen some claims that it does change. So is it safe to use them? And what are the other available options?

Share this post


Link to post
Share on other sites
Advertisement
No, it doesn't change. It cannot change. It never changes while the system is running. People who claim it changes are not using it properly. You may safely rely on it.
(of course this is from a "normal operation" point of view. If you have hardware faults all bets are off, but that is extremely rare).

Other options are limited. The whole point of the QueryPerformanceCounter/Frequency functions is that they abstract away all the different processor speeds/power saving modes/different cores for you and always return a valid result. You could use GetTickCount (and all variants thereof) but their accuracy tends to break down around the 10ms mark. There's also probably a Unix/Linux equivalent for QPC/F but I have not looked into it.

Edit: also, it does not change while the system is running, i.e. it may change from one boot to the next and from one system to the next. This may seem like a tautology but you'd be surprised how many people stop reading at "cannot change" and try and recycle their frequency on multiple different systems. Then the same people cry foul at the documentation. dry.png

Share this post


Link to post
Share on other sites
There were a few series of dodgey motherboards built a long time ago, where Win XP had a bug where the timer values could change, which completely breaks most games on those PC's. For people with these buggy computers, there is a WinXP patch to fix the issue.

So -- in general, the MSDN is right.
Technically, it's wrong, but only because of a few old bits of bad hardware (that break most games, not just yours), which can be fixed with a WinXP patch.

Share this post


Link to post
Share on other sites
Thanks for replying. In fact i have been using them since and never had any problems with them. Only recently a found some claims on the internet that the frequency could change. I guess they forgot to mention that it affected only certain (buggy) motherboards.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!