[SDL] Higher precision SDL_GetTicks()?
havoc at ghdigital.com
Tue Feb 7 21:10:31 PST 2012
For Linux I just use:
struct timespec ts;
return (double) ts.tv_sec + ts.tv_nsec / 1000000000.0;
On 02/07/2012 01:14 PM, Patrick Baggett wrote:
> Well, Wiki probably isn't the best source for this, but:
> In particular, (since it looks like MacOS implies Intel CPUs about 99% of the time)
> For Pentium 4 processors, Intel Xeon processors (family [0FH], models [03H and higher]); for Intel Core Solo and Intel Core Duo processors (family [06H], model [0EH]); for the Intel Xeon processor
> 5100 series and Intel Core 2 Duo processors (family [06H], model [0FH]); for Intel Core 2 and Intel Xeon processors (family [06H], display_model [17H]); for Intel Atom processors (family [06H],
> display_model [1CH]): the time-stamp counter increments at a constant rate. That rate may be set by the maximum core-clock to bus-clock ratio of the processor or may be set by the maximum resolved
> frequency at which the processor is booted. The maximum resolved frequency may differ from the maximum qualified frequency of the processor.
> This is probably true of Intel i3/5/7 as well, so you should be reasonably safe.
> If you look at http://hg.libsdl.org/SDL/rev/6bd701987ba9 on line 5.25, you can see that these are implemented in a reasonable way for UNIX-like OSes, so you should be able to use the above-mentioned
> SDL functions portably. Unless you're running on older AMD CPUs (K8, not K10), then I wouldn't worry too much. I don't think you'll need to mess with the power management unless you're running on an
> older machine.
> SDL mailing list
> SDL at lists.libsdl.org
Author of DarkPlaces Quake1 engine - http://icculus.org/twilight/darkplaces
Co-designer of Nexuiz - http://alientrap.org/nexuiz
"War does not prove who is right, it proves who is left." - Unknown
"Any sufficiently advanced technology is indistinguishable from a rigged demo." - James Klass
"A game is a series of interesting choices." - Sid Meier
More information about the SDL