I need a monotonous clock that can be used to calculate intervals. Requirements:
- It should be monotonous, it should not be affected by the time of the device.
- It is not necessary to reset during an application session. (The same era for all return values ββin a session)
- It should represent real-time seconds (not processor seconds), should not depend on the number of threads / processes running at that time.
- Allowed seconds resolution.
In my research, I found Candidates:
std::clock()(ctime) - It seems you need to use cpu secondsboost::chrono::steady_clock()- Does he use cpu seconds? Can the era change during the application session(launch-end)?- Platform-specific methods (
clock_gettime, mach_absolute_time).
Have you ever encountered such a problem and what solution did you choose? Is it a steady_clock()reliable multi-platform?
source
share