Skip to main content
GameDev.net gamedev.net
🔒 Locked

QueryPerformanceCounter Performance

Started by UBrothers Apr 17, 2006 at 4:42 AM 5 replies 5.3k views
Original Post
UBrothers
UBrothers
Hi all, this is not really a DirectX question, but I am developing game that uses DirectX and I wan to know your opinion on this: I am using QueryPerformanceCounter function for game timing and I am calling it quite often per frame (each animated object is timed using this function), so what do you think - is it ok to call QueryPerformanceCounter function often ? Do you think, that it can lower the framerate ? Thanx, Stf
KulSeran
KulSeran
You should probably just call it once per frame.
And set up a delta-time for the frame, not a delta-time per object.
blaze02
blaze02
I agree with KulSeran. While I don't think the calls will hurt performance, its just really bad practice.
Evil Steve
Evil Steve
I'd advise wrapping it into a global timer class or something, that'll only actually call QueryPerformanceCounter every frame. The performance shouldn't be too bad, but it's best to avoid calling it too often.

EDIT: Waaay too late [smile]
UBrothers
UBrothers
Thanx, i will try to change my Timer class a little and i will tell you a fps performance results.
jollyjeffers
jollyjeffers
Quote:
Original post by UBrothers
this is not really a DirectX question
Seems you've got an answer now, so no point in moving it... but in future, general (Windows) API and programming questions are more suited to General Programming or possibly Game Programming [smile].

Cheers,
Jack
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ |
Dtag
Dtag
Hey

Performance Counters are very precise, but the precision comes at a quite high cost. Querying the timer too often will hurt performance. If you really need to do lots of queries, you should try looking at RDTSC.
More information on timer performance can be found here:
http://www.nvidia.com/object/timer_function_performance.html

Edit: If your really using this for animation of objects, you should do what the first replyers suggested. If you need further timing functions ( say for an in-game profiler or anything similar ), it may be worth looking at RDTSC etc.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.