Skip to content

Commit

Permalink
Replace usage of time.time() with time.monotonic() for duration calcu…
Browse files Browse the repository at this point in the history
…lations

Signed-off-by: Mynhardt Burger <Mynhardt.Burger@ibm.com>
  • Loading branch information
mynhardtburger committed Oct 4, 2024
1 parent 8a904a1 commit 039184f
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 039184f

Please sign in to comment.