Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I was wondering if it would be a good idea to use the steady_clock class (in the C++ std libraries) for game timing. What are the pros/cons of using it as opposed to using a game library's timing mechanism?

share|improve this question
    
Perhaps you should take a look into the source code of a game library's timing functions; behind them you should simply find some system-specific API calls, nothing custom or arcane. The game library should simply be using the best standard timer choice, that is, one which is high resolution and accurate. –  Ricket Nov 25 '12 at 4:40
add comment

1 Answer

up vote 1 down vote accepted

As far as I understood std::chrono you cant be sure to get a high resolution timer with std::steady_clock. So you might loose some accuracy on some system if the high resolution timer is not available as steady clock. I considered that too a while ago but than I read about steady clock and high resolution. I just can't find the reference at the moment.

Edit:

Here it is http://www.cplusplus.com/reference/chrono/high_resolution_clock/ there you can see that the high resolution clock has a is_steady member. So for me it seems you can also get unsteady high resolution clocks. And on my system this member returned false. If you are fine with low resolution I think theres nothing against using steady_clock.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.