qm_report/decorators.py

16 lines
376 B
Python

from time import time
def timer(func):
"""
Shows the execution time of the function object passed.
"""
def wrap_func(*args, **kwargs):
start = time()
result = func(*args, **kwargs)
end = time()
print(
f"Function {func.__name__!r} executed in {(end-start): .4f} seconds")
return result
return wrap_func