I'm trying to find a decent replacement on Windows for clock_gettime(CLOCK_MONOTONIC)
and mach_absolute_time
.
GetTickCount
is annoying because it's deliberately biased: when the system resumes from suspend or hibernation, it seems Windows works out how long it was suspended (from motherboard) then adds that to the tick count to make it look like the tick carried on while the system was powered down.
QueryUnbiasedInterruptTime
is friendlier: it's a simple, seemingly-reliable counter that just returns the time the system has been running since boot.
Now, I've experimented with QueryUnbiasedInterruptTime
to see what happens when the computer enters each of: sleep, hybrid sleep, and hibernation. It appears that it's correctly updated so that it appears to be monotonic (ie, the system stashes it before hibernation and restores it so that applications aren't confused).
But, there's a note here on the Python dev pages (which, by the way, are a very helpful resource for time function reference!):
QueryUnbiasedInterruptTime() is not monotonic.
I presume someone did a test to determine that. Is that information accurate? If so, out of interest I wonder what you have to do to get the return value to go backwards.