Module with useful functions

This commit is contained in:
David Doblas Jiménez 2021-06-03 19:38:23 +02:00
parent 5ecda2c66c
commit aadf2acc54

16
src/Python/utils.py Normal file
View File

@ -0,0 +1,16 @@
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