Skip to content

Commit

Permalink
Stopwatch now uses time.monotonic.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Jun 27, 2023
1 parent aba4d70 commit e960374
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions newsfragments/+45048c4e.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Stopwatch now uses ``time.monotonic``.
4 changes: 2 additions & 2 deletions tempora/timing.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ def reset(self):
del self._start

def _diff(self):
return datetime.datetime.now(datetime.timezone.utc) - self._start
return datetime.timedelta(seconds=time.monotonic() - self._start)

def start(self):
self._start = datetime.datetime.now(datetime.timezone.utc)
self._start = time.monotonic()

def stop(self):
self.elapsed += self._diff()
Expand Down

0 comments on commit e960374

Please sign in to comment.