-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed
Description
tic() and friends use the system time for measuring duration. This can be problematic if the system time is changed between measurements:
tic()
toc()
now = int32(time())
tic()
# move system time backwards
run(`date --set="@$(now-60)"`)
toc()
# restore system time
run(`date --set="@$(now)"`)
yields
elapsed time: 0.01815319061279297 seconds
Mon Mar 4 16:05:30 EST 2013
elapsed time: -60.13567399978638 seconds
Mon Mar 4 16:06:30 EST 2013
It would be better to use a monotonic clock for any place where duration is being measured, independent of datetime. Examples:
http://linux.die.net/man/3/clock_gettime
http://docs.python.org/3/library/time.html#time.monotonic
Metadata
Metadata
Assignees
Labels
No labels