Jump to content
  • Advertisement
Sign in to follow this  
nagromo

Timer Resolution

This topic is 5020 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 am writing a RPG in C# for both Windows and Linux, and I have been having some difficulties with the timer code. Under Windows System.Environment.TickCount and other .Net methods have horrible resolution so I use QPF/QPC. However while running Linux that is not an option, so I want to use System.Environment.TickCount. Although this returns a value in milliseconds it has resolution of one millisecond (it will return 1225920 then 1225921 and so on). Is this accurate enough for games, or would you reccomend implementing another method?

Share this post


Link to post
Share on other sites
Advertisement
Generally speaking, timer resolution doesn't matter in games. Unless the timer is extremely low resolution, you should worry.

Share this post


Link to post
Share on other sites
It really depends on the application, but usually timer resolution does matter. If you are timing the duration of each frame, then you need a timer whose resolution is at most half of the frame duration (Nyquist and such). If the resolution is higher, then sometimes you will get frames with a duration of 0 and that can cause headaches. So, if your frame rate is 100 fps, a timer with a 5ms resolution should be sufficient.

Share this post


Link to post
Share on other sites
quick google,

http://www.chemie.fu-berlin.de/cgi-bin/man/sgi_irix?timers+5

is that what you're after?

Share this post


Link to post
Share on other sites
but since it's in in C#, you should really have a high-level, high performance counter query somewhere in there. in Win32, it's QueryPerformanceCounter()

this also recommends gettimeofday(), but I doubt it very much.

http://www-106.ibm.com/developerworks/library/l-rt1/

Share this post


Link to post
Share on other sites
but since it's in in C#, you should really have a high-level, high performance counter query somewhere in there. in Win32, it's QueryPerformanceCounter()

this also recommends gettimeofday().

That should return time of day in seconds and microseconds.

http://www-106.ibm.com/developerworks/library/l-rt1/

Share this post


Link to post
Share on other sites
for C++ at least, unix platforms' time.h has time return functions in the microsecond resolution, natively. I'm surprised Windows does not.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!