Understanding steady clocks in C++ benchmarking
This easy C++ question tests whether you know the difference between wall-clock time and monotonic time — a distinction that matters whenever you're measuring elapsed duration, even for rough benchmarking. It's the kind of language-level detail that comes up in code reviews at firms that care about correctness.
The question probes your familiarity with the std::chrono library and, more broadly, why certain clock types are suitable for measuring intervals and others are not. A "steady" clock moves forward at a constant rate and is immune to system adjustments; an ordinary wall clock can jump backward or stall if the system administrator changes the time. When you're timing code, you want to measure real elapsed time, not get tripped up by clock corrections or daylight-saving adjustments.
- Wall-clock time vs. monotonic time
- Clock adjustments and system time skew
- Choosing the right clock type for your use case