(no title)
thxg | 3 years ago
On Linux it can be argued that CLOCK_MONOTONIC_RAW should be used for durations. From the Linux man page:
CLOCK_MONOTONIC_RAW (since Linux 2.6.28; Linux-specific)
Similar to CLOCK_MONOTONIC, but provides access to
a raw hardware-based time that is not subject to
NTP adjustments or the incremental adjustments per‐
formed by adjtime(3). This clock does not count
time that the system is suspended.
There is also CLOCK_BOOTTIME to keep counting time while suspended: CLOCK_BOOTTIME (since Linux 2.6.39; Linux-specific)
A nonsettable system-wide clock that is identical
to CLOCK_MONOTONIC, except that it also includes
any time that the system is suspended. This allows
applications to get a suspend-aware monotonic clock
without having to deal with the complications of
CLOCK_REALTIME, which may have discontinuities if
the time is changed using settimeofday(2) or simi‐
lar.
AnIdiotOnTheNet|3 years ago
As I understanding it, when you're measuring real actual time you want the adjustments because otherwise you'll end up less accurate.
CLOCK_MONOTONIC_RAW is useful if you expect to use some other synchronization.
touisteur|3 years ago