Sign in to follow this  

Timer Resolution

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

This topic is 4857 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this