Expand description
Cheap monotonic clocks.
now_ns is the precise monotonic clock (CLOCK_MONOTONIC through the vDSO on Linux,
QueryPerformanceCounter on Windows). coarse_ns is cheaper and has the resolution of
the kernel tick: CLOCK_MONOTONIC_COARSE on Linux (same epoch as now_ns); elsewhere it
is the precise clock. Both count nanoseconds from an arbitrary fixed point.
Functions§
- coarse_
ns - Nanoseconds on the cheapest monotonic clock (kernel-tick resolution on Linux).
- now_ns
- Nanoseconds on the precise monotonic clock.
- process_
cpu_ ns - CPU time (user and system) used by the whole process so far, in nanoseconds:
CLOCK_PROCESS_CPUTIME_IDon Unix,GetProcessTimeson Windows (100 ns steps, updated at the scheduler tick). For measurements such as “an idle server uses no CPU”. - wall_ns
- Nanoseconds since the Unix epoch on the wall clock (0 if it is set before 1970). On Linux a
direct
clock_gettime:SystemTimecosts code for its error path.