[Lazarus] Portable way to get accurate timestamps?

Lukasz Sokol el.es.cr at gmail.com
Wed Feb 23 10:14:12 CET 2011


On 22/02/2011 15:02, Bo Berglund wrote:

> 
> Thanks,
> I have now tested it (on Windows) and found that although the
> QueryPerformanceCounter gives more resolution it is also drifting
> compared to real time (77 ms in 30 s) making it rather unusable...
> It would be good for a highres timer but not for keeping track of time
> over longer periods.

Well what do you expect from _non-military_ grade hardware? 
No quartz of whatever form is ever perfect in every temperature. 

Try finding the master quartz on your main board and try using the 'freeze spray' on it
or just touch it with your finger,
or (dangerous) solder a small trimmer capacitor parallel to one of the decoupling caps there, 
and you'll discover what happens... the oscillators in the chipsets probably have some 
temperature compensation, but not one is ever perfect, _and_ it is also affected by the chipset
(and so the logic gates driving the quarts) heating up...

Internal clock base is the only reference for _whatever_ you run in software.
People have discovered remote daytime clock update over internet for this;
But to rdtsc() and compare that to external source ... hmm.

If in Linux, there is a feature I read about on LKML, that lets you connect external
stable clock signal to the serial port and drive the OS wall clock that way;
(IIRC and IIUC applies...)
I think it was called PPS or PPM. It was merged 2-3 stable releases ago I think.

L.






More information about the Lazarus mailing list