On Sun, 20 Feb 2011 22:16:25 -0500, waldo kitty <[email protected]> wrote:
>On 2/20/2011 08:46, Luca Olivetti wrote: >> Al 20/02/11 12:42, En/na Bo Berglund ha escrit: >> >>> I wonder if GetTickCount will get me a better value to milliseconds >>> than Now()? >> >> Not under linux: >> >> function GetTickCount: DWord; >> begin >> Result := DWord(Trunc(Now * 24 * 60 * 60 * 1000)); >> end; > >i gotta ask... is that even accurate? what are those "ticks" that are being >counted? by the above, they surely do not appear to be the machine's actual >clock timer ticks... can those even be accessed in today's world or do we >really >need to revert some things like this back to the DOS world??? This is a Delphi wrapped API call in Windows that returns the number of milliseconds since Windows started. I had the impression that they were at least locked to the PC clock somehow and actually gave a millisecond resolution, but now I believe that the "counter" is in fact working in a different way than one would believe by the name. When I run a test against a fairly accurate GPS time source I see that there is an uncertainty of about 16 ms in the time given such that if GetTickCount is executed at exactly 1 second intervals the last two digits of the value is not the same as it should be. Instead it slowly (over a period of 16 seconds) reduces by 16 ms and then suddenly restores to a max value. It is like a superimposed sawtooth with an amplitude of 16 ms. The posted variation is apparently a Linux platform compatible version that returns a millisecond value the same way as the Windows version does, since there is no Windows GetTickCount API call in Linux. I used this also on Windows in my tests and then the value does not exhibit the sawtooth anymore. So I assume that Now() gets its time from another source than the timer counter driving GetTickCount and this is more accurate. -- Bo Berglund Developer in Sweden -- _______________________________________________ Lazarus mailing list [email protected] http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
