I've been tinkering with microcontroller code and have learned about "real time clocks" and how computers attempt to keep accurate time.
More recently, I've become loosely familiar with NTP at the UDP level and realized that I could measure the clock drift over time just by repeatedly fetching hardware time and NTP time and comparing their differences over time.
I found that my desktop machine's RTC drifted by about 6 seconds in 33 hours. This kind of error is acceptable for some applications and unacceptable for others.
I did this on a Windows 10 machine, but I first
- Turned off the automatic system clock update. Presumably, this is periodically fetching NTP to stay accurate.
- Set the machie to never turn off
The scripts require numpy
, matplotlib
, and ntplib
. To measure your own setup, simply run
python clock_drift_record.py
And you can visualize the data recorded to a .npy
or .bin
file by running
python clock_drift_plot.py clock_drift_0123456789ABCDEF.bin