Module with useful functions

This commit is contained in:
daviddoji committed 2021-06-03 19:38:23 +02:00
1 parent 5ecda2c66c
commit aadf2acc54
1 file changed
+16
+16
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