• Advertisement

Archived

This topic is now archived and is closed to further replies.

Timers

This topic is 5905 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''m using QueryPerformanceCounter to perform the timing in my game framework, and I''m finding that it "hickups" quite a bit. Is there a better timer for me to use, or should I smooth things out with averages? (which would decrease absolute accuracy). Thanks, Mal.

Share this post


Link to post
Share on other sites
Advertisement
Not quite sure what you mean by ''Hiccups'' but it has always worked fine for me. Pay a visit to the NVidia wbsite for a comparison on timing mechanisms - there is source for the timers, and exe file which times the timers (so you can see if it is as accurate as you think).

Hope this helps.

Neil

Share this post


Link to post
Share on other sites
1. Smooth the timing out if it''s being used as some sort of "elapsed" time between frames. This tends to help a great deal. Smooth over say 10 frames, and also include a trap to stop stuff going crazy if there''s a particularly big delay.

2. QPF() is the most precise platform/CPU independent timer you get in Windows.

3. Any simple "how long did this frame take" timer isn''t going to be totally accurate on a pre-emptive multitasking OS (like Windows) anyway. Your main process thread gets it''s time slice (quantum) which lasts some variable amount (depending on whether you got messages, whether you were starved last time etc). After that timeslice, even if you haven''t finished a frame, control will be snatched away and given to the next scheduled thread in the system.
Another process could end up getting a longer time slice than usual because of some operation or message. You have no control over what they''re doing so your app can be affected by them.

4. Make sure you have one of the "greedy" message pumps so that Windows doesn''t decide your app has gone idle and decide to start some helpful process such the disk defragmenter!

5. Other common "nasty" threads/processes which''ll give your app "hiccups" are the Task Scheduler (which on some machines is checking for Windows Critical Updates every second) and MS Office FindFast (which indexes your HD from time to time).

6. Theres also some things you don''t have control over which are caused by hardware and drivers. Network cards and misconfigured NetBIOS settings are common culprits for stalling the whole machine every so often. As are some HD drivers etc!

7. Final stutter cause is wild memory access patterns. Memory in a virtual memory system is NOT "Random Access Memory" - it''s paged - if a page hasn''t been touched recently you''ll get a page fault. Another name for a page fault is a load from the hard disk. Great for causing stutters in smooth apps. Access memory sequentially, accesses near in time should be near in address.

--
Simon O''''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites
quote:
Original post by S1CA
4. Make sure you have one of the "greedy" message pumps so that Windows doesn''t decide your app has gone idle and decide to start some helpful process such the disk defragmenter!


What do you mean?

Superpig
- saving pigs from untimely fates
- sleeps in a ham-mock at www.thebinaryrefinery.cjb.net

Share this post


Link to post
Share on other sites
quote:

superpig:

What do you mean?



He means greedy PeekMessage.

Unlike the GetMessage function, the PeekMessage function does not wait for a message to be placed in the queue before returning.

So if you use GetMessage, Windows thinks, your app is idle and starts thinking now would be a good time to clean house.

Edited by - Abstract Thought on November 23, 2001 12:48:34 PM

Share this post


Link to post
Share on other sites
Oh... right. Never heard it called ''greedy'' before though.

Superpig
- saving pigs from untimely fates
- sleeps in a ham-mock at www.thebinaryrefinery.cjb.net

Share this post


Link to post
Share on other sites

  • Advertisement