Jump to content

  • Log In with Google      Sign In   
  • Create Account


QueryPerformanceFrequency/QueryPerformanceCounter


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Aerodactyl55   Members   -  Reputation: 149

Like
0Likes
Like

Posted 18 March 2012 - 06:10 AM

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?

Sponsor:

#2 Bacterius   Crossbones+   -  Reputation: 8658

Like
0Likes
Like

Posted 18 March 2012 - 08:35 PM

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. Posted Image

The slowsort algorithm is a perfect illustration of the multiply and surrender paradigm, which is perhaps the single most important paradigm in the development of reluctant algorithms. The basic multiply and surrender strategy consists in replacing the problem at hand by two or more subproblems, each slightly simpler than the original, and continue multiplying subproblems and subsubproblems recursively in this fashion as long as possible. At some point the subproblems will all become so simple that their solution can no longer be postponed, and we will have to surrender. Experience shows that, in most cases, by the time this point is reached the total work will be substantially higher than what could have been wasted by a more direct approach.

 

- Pessimal Algorithms and Simplexity Analysis


#3 Hodgman   Moderators   -  Reputation: 29680

Like
0Likes
Like

Posted 18 March 2012 - 09:25 PM

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.

#4 Aerodactyl55   Members   -  Reputation: 149

Like
0Likes
Like

Posted 19 March 2012 - 12:06 AM

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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS