Skip to content

Conversation

SyntaxColoring
Copy link
Contributor

Overview

A lot of Python code (in various projects) was doing stuff like:

start = time.now()
do_stuff()
end = time.now()
duration = end - start

That's not quite right because time.now() can be affected by things like daylight savings time, leap seconds, and NTP adjustments. If we're doing math on timestamps, it needs to come from a monotonic clock. So this switches all (or at least most) of those places to use time.monotonic() instead.

Test Plan and Hands on Testing

None.

Changelog

Basically a global Ctrl+F for time.time(). I replaced it with time.monotonic() when it was obvious to me that it was only used in the local scope and that math was being done on it. So this excludes things like time() calls that were getting saved in CSV reports.

Review requests

OK with all the hardware-testing changes, or do I need to run that by anybody?

Risk assessment

Low. Changes are trivial.

@SyntaxColoring SyntaxColoring requested review from a team July 28, 2025 22:29
Copy link
Contributor

@mjhuff mjhuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, most definitely. Thank you!

@SyntaxColoring SyntaxColoring merged commit 648a1a9 into edge Jul 29, 2025
57 checks passed
@SyntaxColoring SyntaxColoring deleted the monotonic_time branch July 29, 2025 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants