14 lines
352 B
Python
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
|