[Lazarus] Better implementation of GetTickcount using clock_gettime

Mattias Gaertner nc-gaertnma at netcologne.de
Wed Apr 2 13:10:24 CEST 2014

On Wed, 02 Apr 2014 13:45:08 +0300
Anton Kavalenka <anton.k at tut.by> wrote:

> Yes - CLOCK_MONOTONICC_RAW is prefreable, because general GetTickCount() 
> is number of millisecond ticks since system startup. It cannot be 
> adjusted by time services, it just grows up every 1 msec.
> Ant typical GetTickCount() usage - find a difference between subsequent 
> values.
> It would be amazing when difference gets negative.

The NTP changes in CLOCK_MONOTONIC only accelerates or slows it down. It
tries to fix the ticks for e.g. busy systems or VMs. It is still

CLOCK_MONOTONIC_RAW would better emulate the WinAPI
function GetTickCount. 
I guess most programs need CLOCK_MONOTONIC.
OTOH if you need precision you should not use GetTickCount, so the
discussion is somewhat pointless.


More information about the Lazarus mailing list