Re:Determine durations with monotonic clocks if available
by AnIdiotOnTheNet on Monday January 30, 2023 @09:32AM
(#34579999)
Almost every discussion I've ever seen regarding the use of CLOCK_MONOTONIC_RAW vs CLOCK_MONOTONIC has come down on the side of using CLOCK_MONOTONIC.
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.
Re:Determine durations with monotonic clocks if available
by touisteur on Monday January 30, 2023 @01:18PM
(#34584028)
Beware, while CLOCK_MONOTONIC_RAW has its uses (avoiding clock skew due to NTP when you're synchronising to an external clock) wasn't vDSO'd yet and was slow AF (and causing a syscall...). It's been optimized on later kernels but I was on some RH or LTS branch I was badly bitten by this.
On Linux it can be argued that CLOCK_MONOTONIC_RAW should be used for durations. From the Linux man page:
There is also CLOCK_BOOTTIME to keep counting time while suspended: