Skip to content

Commit

Permalink
Merge pull request #823 from naglis/improve-timing-decorator
Browse files Browse the repository at this point in the history
Improve `@timing` decorator
  • Loading branch information
rdbende committed Jan 4, 2024
2 parents e46afc3 + bb9d1b6 commit 7a7577b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cozy/architecture/profiler.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import time
import logging
import functools

log = logging.getLogger("timing")

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
Expand Down

0 comments on commit 7a7577b

Please sign in to comment.