NDOJ/dmoj/decorators.py
2022-04-16 16:05:55 -05:00

12 lines
No EOL
346 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