Skip to content

Commit 87e71d7

Browse files
authored
Merge pull request #457 from mynhardtburger/use-monotonic-time
Replace usage of time.time() with time.monotonic() for duration calcu…
2 parents 8a904a1 + 039184f commit 87e71d7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/python/alog/alog.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -822,11 +822,11 @@ def __init__(self, log_fn, format_str="", *args) -> None:
822822

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

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

0 commit comments

Comments
 (0)