Discussion:
[fpc-devel] High performance Linux timer
Graeme Geldenhuys
2008-05-18 20:38:36 UTC
Permalink
Hi,

Does anybody know if there is a Linux (or generic Unix) high
performance timer API available. Something like the Win32 API
QueryPerformanceCounter()?


Regards,
- Graeme -


_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
Johann Glaser
2008-05-18 21:05:08 UTC
Permalink
Hi!
Post by Graeme Geldenhuys
Does anybody know if there is a Linux (or generic Unix) high
performance timer API available. Something like the Win32 API
QueryPerformanceCounter()?
Probably the Time-Stamp-Counter for your CPU is of interest for you. See
http://en.wikipedia.org/wiki/Rdtsc for example code.

Bye
Hansi
Felipe Monteiro de Carvalho
2008-05-18 22:25:20 UTC
Permalink
I once implemented a high precision timer on linux, but I don't
remember how I did it. Look at the code here:

http://wiki.lazarus.freepascal.org/EpikTimer
--
Felipe Monteiro de Carvalho
Graeme Geldenhuys
2008-05-19 07:31:13 UTC
Permalink
Post by Felipe Monteiro de Carvalho
I once implemented a high precision timer on linux, but I don't
http://wiki.lazarus.freepascal.org/EpikTimer
Thanks, I'll have a look at the code for more details.
Felipe Monteiro de Carvalho
2008-05-19 12:54:18 UTC
Permalink
On Mon, May 19, 2008 at 4:31 AM, Graeme Geldenhuys
Timestamp counter from the CPU (assuming we are speaking of RDTSC) is
susceptible to many issue...
* Nanosecond resolution is supported on Intel Pentium versions with a Timestamp Counter.
* Microsecond system clock is the default timebase. <<<
The default timebase doesn't use the hardware directly.
--
Felipe Monteiro de Carvalho
Vladimir Zhirov
2008-05-19 10:42:00 UTC
Permalink
Hi,
Post by Graeme Geldenhuys
Does anybody know if there is a Linux (or generic Unix) high
performance timer API available. Something like the Win32 API
QueryPerformanceCounter()?
Graeme, maybe this link will help:
http://www.gamedev.net/community/forums/topic.asp?topic_id=127700

There are some functions mentioned there in addition to RDTSC:
- gettimeofday
- clock_gettime
- ftime
Post by Graeme Geldenhuys
Anybody know what Win32's QueryPerformanceCounter() uses internally to
get a stable timer? Or is QueryPerformanceCounter also susceptible to
powersaving features?
I found an article named "Beware of QueryPerformanceCounter()" on
http://www.virtualdub.org/blog/pivot/entry.php?id=106
that gives some information about this function.
It will not answer your questions directly, but may be useful.
--
Regards,
Vladimir
Continue reading on narkive:
Loading...