Jump to content
  • Advertisement
Sign in to follow this  
Arunas

game timing issue

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

Is there any platform independent library providing a high-resolution clock? Such as if I would use QueryPerformanceCounter under win32. "time.h" clock() doesn`t fit my needs, because it measures time a process execution time and its not a real time if application saves CPU. I was using SDL`s SDL_GetTicks(), but the values it returns are too unprecise.

Share this post


Link to post
Share on other sites
Advertisement
If the target-platform supports assembler, you could
use the rdtsc count (it doesn't get any higher-precision
than this).

Note that rdtsc is NOT dualcore/HT-safe (just like
queryPerformanceCounter isn't either!).

It is possible to make it safe though, using threadAffinity
and apic (check the intel site on this one).
Btw, I'm writing an article on this topic - probably will
take me some time before I finish though :)

Regards

Share this post


Link to post
Share on other sites
Well, I know I could use some platform or CPU specific ways to implement a hi-res timing, but I wondered If there is any portable library providing such thing. Anyway, thanks for help, I'm looking forward for to article.

Share this post


Link to post
Share on other sites
You may want to have a look at this. It may not solve all the problems and be truly portable but its an interesting read if you plan to roll your own.

Chris

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!