game timing issue

Started by
3 comments, last by spookycat 18 years, 5 months ago
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.
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

visit my website at www.kalmiya.com
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.
I'm sure many people have written one, but there is no standard cross-platform library.
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!
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

This topic is closed to new replies.

Advertisement