Jump to content
  • Advertisement
Sign in to follow this  
RonHiler

QueryPerformanceCounter

This topic is 3066 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

I notice Microsoft KB: Q274323 here:

http://support.microsoft.com/kb/274323

is marked as "retired". Does this mean the QPC jumps are no longer an issue with current hardware? Or am I looking in the wrong place?

Share this post


Link to post
Share on other sites
Advertisement
No. It means:
Quote:
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.


Having said that, Windows Vista and Windows 7 will use more reliable timers if the CPU supports them. However, not all CPUs do (only the latest two or so generations), and Windows XP will not use them, even if they're present.

Share this post


Link to post
Share on other sites
I see. So we are still in the age of comparing a pair of QPC/QPF calls versus a pair of GetTickCount calls to find jumps and making adjustments. Or would there be a better method I should be using?

Share this post


Link to post
Share on other sites
QPF/QPC will resort to using gettick if it has to. So it will be backwards compatible to some degree by default. It won't necessarily report a frequency of 1000, but the actual resolution will be on par. ie, qpf may give 27 million, but qpc will give a value for which 27 thousand is a factor.

Here is a slightly cleaner msdn article on the issue. /Though it doesn't point out what I mentioned/

edit:
"These APIs may make use of RDTSC, but might instead make use of a timing devices on the motherboard or some other system services that provide high-quality high-resolution timing information."
I have noticed on some different systems I have access to that the resolution can be different by a number of decimal places. On a core 2 quad machine running XP I saw the scenario I mention above (it basically lies about the resolution but will run correctly regardless). On my core 2 quad with windows 7 it is 2,317,734ths of a second, on a phenom 2 with vista it was 140,000ths roughly (cant remember the exact figure, but it wasn't showing signs of using "gettickcount").

edit:
The comment by "Sil B" on that page is interesting.

Share this post


Link to post
Share on other sites
Quote:

I see. So we are still in the age of comparing a pair of QPC/QPF calls versus a pair of GetTickCount calls to find jumps and making adjustments. Or would there be a better method I should be using?

It's not that hard to write a `driver' for the newer HPET, which gives you a higher resolution and no hairy bugs (yet). The biggest stumbling block was signing the mini kernel-mode driver that maps physical memory, but I finally got around to that today (albeit with a test certificate).
See http://wassenberg.dreamhosters.com/articles.html and http://trac.wildfiregames.com/browser/ps/trunk/source/lib/sysdep/os/win/whrt
.

Quote:
The comment by "Sil B" on that page is interesting.

Atomic updates are one way to do it, but you can also force your *callers* to ensure they got a consistent value (see disassembly of kernel32!GetTickCount).

Share this post


Link to post
Share on other sites
The invariant TSC is a nice simple timer you can use on processors that support it - see 19.11 in this document http://pdos.csail.mit.edu/6.858/2010/readings/ia32/ia32-3b.pdf. You just check if it's supported and use the old 'RDTSC' instruction if it is. 'RDTSCP' is a new thing separate to the invariant TSC but that has some performance implications since it's a serializing instruction.

Note: Although most of the documentation about invariant TSC is based on Intel processors, you can use the same cpuid check on AMD systems, they also have processors with an invariant TSC.

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!