module

RoughTime

Cheap, low resolution clocks for hot paths.

Reads the kernel's coarse clocks, which are served from the vDSO/commpage without a syscall and only updated at the timer tick (typically 1-4 ms on Linux). No background thread is needed, so nothing wakes up when idle.

NOTE: RoughTime.instant must only be compared with other RoughTime.instant values, not with Time.instant. On Linux Time.instant uses CLOCK_BOOTTIME (includes suspended time) while there's no coarse variant of that clock, so CLOCK_MONOTONIC_COARSE is used here.

Constants

MONOTONIC_CLOCK = LibC::CLOCK_MONOTONIC_COARSE
REALTIME_CLOCK = LibC::CLOCK_REALTIME_COARSE
UNIX_EPOCH_IN_SECONDS = 62135596800_i64

Class methods

instant
Source
unix_ms
Source