Skip to content

Commit

Permalink
use time.perf_counter() instead of time.time() to measure running time
Browse files Browse the repository at this point in the history
  • Loading branch information
ilius committed Sep 27, 2024
1 parent e3f2a76 commit 8c89ec6
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pyglossary/glossary.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# with this program. Or on Debian systems, from /usr/share/common-licenses/GPL
# If not, see <http://www.gnu.org/licenses/gpl.txt>.

from time import time as now
from time import perf_counter as now
from typing import TYPE_CHECKING

from .core import log
Expand Down
2 changes: 1 addition & 1 deletion pyglossary/glossary_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
)
from pickle import dumps as pickle_dumps
from pickle import loads as pickle_loads
from time import time as now
from time import perf_counter as now
from typing import (
TYPE_CHECKING,
cast,
Expand Down
2 changes: 1 addition & 1 deletion pyglossary/langs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def _addLang(self, lang: "Lang") -> None:
self[name.lower()] = lang

def load(self) -> None:
from time import time as now
from time import perf_counter as now

if len(self) > 0:
return
Expand Down
6 changes: 3 additions & 3 deletions pyglossary/plugins/aard2_slob.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,15 +318,15 @@ def open(self, filename: str) -> None:
self._filename = filename

def finish(self) -> None:
from time import time
from time import perf_counter

self._filename = ""
if self._slobWriter is None:
return
log.info("Finalizing slob file...")
t0 = time()
t0 = perf_counter()
self._slobWriter.finalize()
log.info(f"Finalizing slob file took {time() - t0:.1f} seconds")
log.info(f"Finalizing slob file took {perf_counter() - t0:.1f} seconds")
self._slobWriter = None

def addDataEntry(self, entry: "EntryType") -> None:
Expand Down
2 changes: 1 addition & 1 deletion pyglossary/plugins/stardict.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
splitext,
)
from pprint import pformat
from time import time as now
from time import perf_counter as now
from typing import (
TYPE_CHECKING,
Any,
Expand Down

0 comments on commit 8c89ec6

Please sign in to comment.