4 ms·
> (3) `time.time()` is not monotonic. I just winced in pain thinking of the ways that can bite you. I guess in a cloud/virtualized environment with many short
by jrumbut 4y ago
> (3) `time.time()` is not monotonic.
I just winced in pain thinking of the ways that can bite you. I guess in a cloud/virtualized environment with many short lived instances it isn't even that obscure an issue to run into.
A nice discussion on Stack Overflow:
https://stackoverflow.com/questions/64497035/is-time-from-time-h-monotonic https://stackoverflow.com/questions/64497035/is-time-from-ti...
- hansvm 4y agoA lot of the places you use time.time and would be bitten by non-monotonicity you probably want something like time.perf_counter, which is useless for measuring absolute time but perfect for calculating time elapsed.
- rkangel 4y agoYes. When people write `time.time()` they almost always actually want `time.monotonic()`.
- flutas 4y ago> I just winced in pain thinking of the ways that can bite you. Something similar caused my favorite bug so far to track down. We were seeing odd spikes in our video playback analytics of some devices watching multiple years worth of video in < 1 hour. System.currenTimeMillis() in Java isn't monotonic either is my short answer for what was causing it. Tracking down _what_ was causing it was even more fun though. Devices (phones) were updating their system time from the network and jumping between timezones.
- jrumbut 4y agoThat's a bad day at the office when you have to go and say "hey remember all that data we painstakingly collected and maybe even billed clients for?"
- flutas 4y agoLuckily I worked for the company that made the analytics tools and consumed them! Bosses actually came to us because our analytics team was trying to figure out who was causing it, because it had been caught by the team doing checks against the data. (a playback period should never have had > 30s of time)