17 lines
413 B
Python
17 lines
413 B
Python
|
|
from functools import wraps
|
|
|
|
|
|
def timeit(name):
|
|
def profile(original):
|
|
import time
|
|
@wraps(original)
|
|
def wrapper(*args, **kwargs):
|
|
t0 = time.perf_counter()
|
|
result = original(*args, **kwargs)
|
|
t1 = time.perf_counter()
|
|
print(f"Time to evaluate {name}: {t1 - t0:.3f} s\n")
|
|
return result
|
|
return wrapper
|
|
return profile
|