Re: [fpc-devel] High performance Linux timer

2008-05-19 Thread Graeme Geldenhuys

Felipe Monteiro de Carvalho wrote:

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



Thanks, I'll have a look at the code for more details. From the wiki, it 
sounds like there might be some issues EpikTimer implementation though.


 *  Timestamp Counter.
 * Pentium IV 3,2Mhz on Windows and Linux with great precision (~ 
3,220,000,000 ticks per second)



Timestamp counter from the CPU (assuming we are speaking of RDTSC) is 
susceptible to many issue. eg: A Intel P4 3.2Mhz does not always produce 
3,220,000,000 ticks per second. Powersaving features like SpeedStep, 
Hibernate etc all affect the CPU clock speed. Also on a multi-core 
system, not all cores are guaranteed to run at the same clock speed.


Above information was gathered from the WikiPedia article.
  http://en.wikipedia.org/wiki/Rdtsc

Anybody know what Win32's QueryPerformanceCounter() uses internally to 
get a stable timer?  Or is QueryPerformanceCounter also susceptible to 
powersaving features?



Regards,
  - Graeme -


___
fpGUI - a cross-platform GUI toolkit using Free Pascal
http://opensoft.homeip.net/fpgui/


___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] High performance Linux timer

2008-05-19 Thread Vladimir Zhirov
Hi,

Graeme Geldenhuys wrote:
 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

 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

___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] High performance Linux timer

2008-05-19 Thread Felipe Monteiro de Carvalho
On Mon, May 19, 2008 at 4:31 AM, Graeme Geldenhuys
[EMAIL PROTECTED] wrote:
 Timestamp counter from the CPU (assuming we are speaking of RDTSC) is
 susceptible to many issue...

Read the line just bellow the one you just quoted:

  *  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
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


[fpc-devel] High performance Linux timer

2008-05-18 Thread Graeme Geldenhuys
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/
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] High performance Linux timer

2008-05-18 Thread Johann Glaser
Hi!

 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


___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] High performance Linux timer

2008-05-18 Thread Felipe Monteiro de Carvalho
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
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel