NDOJ/dmoj/decorators.py

12 lines
346 B
Python
Raw Normal View History

2022-04-16 21:05:55 +00:00
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