Jump to content
  • Advertisement
Sign in to follow this  
X Abstract X

SDL or Boost for Timing?

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


[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
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!