Module with useful functions
This commit is contained in:
parent
5ecda2c66c
commit
aadf2acc54
16
src/Python/utils.py
Normal file
16
src/Python/utils.py
Normal 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
|
Loading…
x
Reference in New Issue
Block a user