3 ms·
if you think dealing with time is a problem, try measuring elapsed time on computers that sleep :) the solution i found (when dealing with this problem in C# a
by novaleaf 10y ago
if you think dealing with time is a problem, try measuring elapsed time on computers that sleep :)
the solution i found (when dealing with this problem in C# a few years ago) is that you need to poll the time in an update loop (running at, say 10hz or whatever resolution you need). if you have a sudden jump in time between two loops, chances are the computer was asleep.
or there was a leap second.
or you are sampling local time instead of UTC and daylight savings just occurred, or the user crossed timezones.
or the user changed their clock manually.
Or the computer resynced with the time server (happens quite often, and can cause negative time to elapse. Better check the CPU for elapsed ticks instead!)
man... this is starting to sound like roll-your-own-cryptography ;)