I am trying to understand the different clocks provided by the c++11 chrono library. From what I read about the different clocks so far, it appeared that for measuring times during program execution, I should be relying on chrono::steady_clock or chrono::monotonic_clock as they are monotonic and thus difference in tick count taken at a particular instance and another one after some time will always be positive for these clocks even if we adjust the system/wall clock.
To test the same, I wrote the following code snippet:
auto nowSystem = chrono::system_clock::now();
auto nowSteady = chrono::steady_clock::now();
auto nowMonotonic = chrono::monotonic_clock::now();
While debugging, I checked the values one all of them were computed. Then I changed my machine time to two hours behind the current time, and did a set next statement so that the three statements are executed again(so as to simulate changing of system time when the application is running). In
The times for all three clocks were the same in the two iterations of the run. How is this possible, ideally the nowSystem time should have been a lower value in the second iteration and others higher value. But all three are lower value!
Why is the monotonicity of the two latter clocks not being maintained?
I am on windows, using VS2013.