game timing issue
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.
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
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement