Sign in to follow this  
Arunas

game timing issue

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
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

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