• Advertisement

Archived

This topic is now archived and is closed to further replies.

High Resolution Unix timer

This topic is 5063 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is there a function to access a high resolution timer on the Unix platform? I''m looking for something similar to the Win32 QueryperformanceCounter.

Share this post


Link to post
Share on other sites
Advertisement
I used gettimeofday() for my engine. It has microsecond resolution (the exact degree I am not sure).

I am not familar with the QueryperfomanceCounter so I am not sure f this will meet your needs.

Share this post


Link to post
Share on other sites
As I recall, there was some kernel hacking related to 2.6, rdtsc, and nanosecond resolution if that''s not enough.

I forget which syscall it was for though, maybe it was gettimeofday

Share this post


Link to post
Share on other sites
SDL has millisecond (ie 1/1000) accuracy to some degree.

Share this post


Link to post
Share on other sites
Looks like SDL seems to be the best option so far. Is there really no built in high resolution timer in Unix? How do you guys write games then? Do all of you use gettimeofday()?

Share this post


Link to post
Share on other sites
quote:
Original post by NuffSaid
Looks like SDL seems to be the best option so far. Is there really no built in high resolution timer in Unix? How do you guys write games then? Do all of you use gettimeofday()?

How is gettimeofday not a built-in high resolution timer? It's what SDL uses if I recall correctly. You can also use clock_gettime for another POSIX option (they're both "new" POSIX from 2001, gettimeofday is also part of BSD 4.3 and has been supported under Linux for quite a while).

[edited by - Null and Void on January 14, 2004 3:55:27 PM]

Share this post


Link to post
Share on other sites
Indeed last I looked SDL_GetTime() does use gettimeofday() internally. Always struck me odd that that we had to jump though hoops for Windows''s QueryPerformanceCounter() functions. ... I probably just don''t know enough details is all

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quake II uses gettimeofday(), too. In my program, it also works nicely, but I don''t need a really precise timer.

Anyways, you can still hack your way down the assembly lane and ask the CPU... thats the rtdsc thingie mentioned before.

QueryPerformanceCounter resolution depends on the device you use. my 1 Ghz Intel has 1/1.000.000 s resolution (microsecond), my 2,5+ Athlon has just about 1/300.000 s which is less than a third...

I don''t believe nanoseconds is realistical timing because in a nanosecond, light only travels 30 cm...

Share this post


Link to post
Share on other sites
I just looked up a C# implementation of QueryPerformanceCounter() (it somewhare on the web, available under the shared source license)

and it uses gettimeofday().

edit:spell

[edited by - C-Junkie on January 22, 2004 3:35:51 PM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
The windows queryperformance crap doesn''t work well on variable clock-rate CPUs (like laptops).

Share this post


Link to post
Share on other sites

  • Advertisement