NDOJ/dmoj/decorators.py
2022-05-14 12:57:27 -05:00

14 lines
352 B
Python

import time
def timeit(method):
def timed(*args, **kw):
ts = time.time()
result = method(*args, **kw)
te = time.time()
if "log_time" in kw:
name = kw.get("log_name", method.__name__.upper())
kw["log_time"][name] = int((te - ts) * 1000)
return result
return timed