• Wouter Klouwen's avatar
    ProcessUNIX: Use monotonic clock in kwsysProcessTimeGetCurrent() for POSIX · 749b7506
    Wouter Klouwen authored
    While a process is running, it is possible for other processes such as
    NTP to alter the system clock in large jumps.
    
    To make the measurement of how long a process has taken to run
    impervious to such large jumps it is helpful to use a monotonic clock.
    This is a clock that takes an arbitrary starting point that does not
    change.
    
    clock_gettime() is a POSIX method that implements this clock. This is
    not available on all platforms, so this commit adds a check for its
    presence. If the monotonic timer is available, use that in
    kwsysProcessTimeGetCurrent(), otherwise falls back to previous
    non-monotonic behaviour.
    749b7506
kwsysPlatformTestsC.c 2.24 KB