Sign in to follow this  

SDL or Boost for Timing?

This topic is 2847 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 guess accuracy is somewhat subjective. Both make use of what the system provides, which is really just access to a millisecond timer. From that you can generate values in any scale - nano, micro/milli, seconds, minutes, hours etc. Also, depending upon how your own program is written, the functions you call, actions you perform etc, will also affect how frequently you can make the calls to get the tick updates.

With SDL you will have to do some coding yourself to generate timing data. Boost will have done more for you. Both will deliver what you want, one with more work than the other, and you decide the precision by which to represent the timing data.

If you are already using SDL then use the GetTicks function to return a milliseconds value (milliseconds since your SDL initialization if I recall correctly) that can be used to calculate an interval for example, which in turn can be represented in nano, micro, milli, seconds, minutes etc.
If you are already using Boost then use that to do the same. Advantage is that Boost has already encapsulated all of those calculations in library and saves you writing it for the most part.
Then again, if you are not using SDL or Boost already, then write your own timer class. Simple enough to write and there are plenty of tutorials on the web, and it would give you an understanding of how the internals work.

My point is that it might not be worth it to go Boost or SDL for just that one piece of functionality. If you do go Boost or SDL, then probably better to plan a more wholesale use of the library.

F451

[Edited by - Fahrenheit451 on February 26, 2010 9:40:36 AM]

Share this post


Link to post
Share on other sites
Some time ago, I went on a GREAT TIMER QUEST to find out which timing api was the best.

I tried a ton of them, including those two, and a bunch of others.

OpenMP's timer was by FAR the most accurate and most reliable. Its also thread-safe, which is awesome, AND it was the easiest to use.

Its a part of your compiler. Look it up.

Share this post


Link to post
Share on other sites

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