Skip to content

Commit

Permalink
Merge pull request #457 from mynhardtburger/use-monotonic-time
Browse files Browse the repository at this point in the history
Replace usage of time.time() with time.monotonic() for duration calcu…
  • Loading branch information
gabe-l-hart authored Oct 4, 2024
2 parents 8a904a1 + 039184f commit 87e71d7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/python/alog/alog.py
Original file line number Diff line number Diff line change
Expand Up @@ -822,11 +822,11 @@ def __init__(self, log_fn, format_str="", *args) -> None:

def _start_timed_log(self) -> None:
"""Get the start time for this timed logger."""
self.start_time = time.time()
self.start_time = time.monotonic()

def _end_timed_log(self) -> None:
"""Gets the end time and prints the end message for this timed logger."""
duration = timedelta(seconds=time.time() - self.start_time)
duration = timedelta(seconds=time.monotonic() - self.start_time)
fmt = self.format_str + "%s"
args = list(self.args) + [str(duration)]
self.log_fn(fmt, *args, extra={"duration": duration.total_seconds()})
Expand Down

0 comments on commit 87e71d7

Please sign in to comment.