From bb9d1b6ae6f4d72fca59774ca200ed76644892be Mon Sep 17 00:00:00 2001 From: naglis <827324+naglis@users.noreply.github.com> Date: Thu, 14 Dec 2023 07:50:35 +0200 Subject: [PATCH] Use `time.perf_counter()` for timing `time.time()` can return a lower value than a previous call if the system clock has been set back between the two calls. --- cozy/architecture/profiler.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cozy/architecture/profiler.py b/cozy/architecture/profiler.py index fd95093b..10a7009b 100644 --- a/cozy/architecture/profiler.py +++ b/cozy/architecture/profiler.py @@ -7,9 +7,9 @@ def timing(f): @functools.wraps(f) def wrap(*args): - time1 = time.time() + time1 = time.perf_counter() ret = f(*args) - time2 = time.time() + time2 = time.perf_counter() log.info('{:s} function took {:.3f} ms'.format(f.__name__, (time2-time1)*1000.0)) return ret