A Monotonic Clock for Elapsed Timing
An elapsed-time clock can measure a duration without relying on jumps in display time caused by wall-clock adjustments.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Trace two readings
A monotonic reading that advances from 42.100 to 42.140 seconds gives forty milliseconds under the timer's units. Its values need no calendar meaning. See timestamps and durations.
Use the correct clock for each purpose
A record identifying when an event happened can keep a wall-clock timestamp too. Clock inputs in tests lets a test verify which difference it uses.[1]
Use two readings from an elapsed-time source
A system's wall clock can be adjusted while a request runs. Measuring through that adjustment can give a misleading difference. A monotonic clock suitable for elapsed durations allows a local before-and-after calculation. See time points and durations.
Read monotonic start
Execute measured operation
Read monotonic end
Duration is end minus start in the clock's units
Check scope and restart behavior
Monotonic readings generally are not calendar instants and may have process or platform-specific reference origins. Use a separate timestamp for reporting event dates. Document resolution and measurement boundaries.