diff --git a/src/Python/utils.py b/src/Python/utils.py new file mode 100644 index 0000000..98d19ab --- /dev/null +++ b/src/Python/utils.py @@ -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