New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace time.time to time.monotonic for the purpose of measuring elapsed time #922
base: main
Are you sure you want to change the base?
Conversation
This looks interesting but I'm puzzled by why you only made replacements in some parts of the code, it looks like there are other places where we use |
@jlaine Thank you for the review.
I simply missed other parts because I did grep-ing |
1541a10
to
2c65163
Compare
…ose of measuring elapsed time
I fixed files in Could you apply such changes on other parts because I couldn't judge if I could replace |
I belatedly realised we have an |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #922 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 30 30
Lines 5816 5816
=========================================
Hits 5816 5816 ☔ View full report in Codecov by Sentry. |
time.time()
is not guaranteed to be monotonic.So
time.monotonic()
should be used instead to measure elapsed time by subtracting two timestamps.(There is a similar method,
time.perf_counter()
, but it's for perf-measuring on short-running code blocks.)Ref: https://www.webucator.com/article/python-clocks-explained/