Skip to main content
GameDev.net gamedev.net
🔒 Locked

Hight resolution portable timer?

Started by Ey-Lord Jan 5, 2007 at 1:30 PM 8 replies 1.7k views
Original Post
Ey-Lord
Ey-Lord
Hello everyone, i currently use something like this :

	QueryPerformanceCounter(&TimeNow_);
	// *1000 because Frequency_ is in second .
	TimeElapsed_ = 1000.0 * (TimeNow_.QuadPart - TimeLast_.QuadPart) / Frequency_.QuadPart;
	TimeLast_= TimeNow_;
Since i need to include windows.h it's obviously not portable ... do you know something as acurate portable ? Thanxs .
Anon Mike
Anon Mike
There isn't any such thing as a portable high-resolution timer. There may be high-resolution timer functions in various third-party libraries, that would probably be your best bet. The closest you'll get in the standard libraries is probably the clock() function.
-Mike
dbzprogrammer
dbzprogrammer
SDL friend.
We should do this the Microsoft way: "WAHOOOO!!! IT COMPILES! SHIP IT!"
dmail
dmail
I am not sure what the precision of the boost timer is, but with a couple of defines you can use platform specfic timers. See this for unix timers.
Ey-Lord
Ey-Lord
I will doublecheck the precision of SDL, i dont remember what it was and if its good enought i'll stick with that, i'm not a big fan of platform specific function if it can be avoided ;)
dmail
dmail
Quote:
Original post by Ey-Lord
I will doublecheck the precision of SDL, i dont remember what it was and if its good enought i'll stick with that, i'm not a big fan of platform specific function if it can be avoided ;)


It's up to you but your reasoning is a little strange. Boost timer and SDL timer are just wrappers for platform specific timers.
WilyCoder
WilyCoder
Time routines are one of the few things I have had to write multiple versions of, for each platform.

Its not that bad.
b2b3
b2b3
On Linux you can use clock_gettime function to obtain time with higher precision than gettimeofday. It supports several different timers and should be available on all newer Linuxes.
To use it, you have to link your program with librt.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.