Friday, 18 November 2022

How to measure the time a script is running despite system time changes?

I'm developing a timeout functionality for an embedded device where the system time is updated via gps. This means I can't just compare two timestamps to get the elapsed time:

import time

t1 = time.time()
# system time change, e.g. from 1970-01-01 to 2022-11-10
t2 = time.time()
elapsed = t2 - t1  # this is now wrong!

Is getting the real elapsed time even possible in this case?



from How to measure the time a script is running despite system time changes?

No comments:

Post a Comment