In [1]:
import time
from functools import wraps
def time_decorator(func):
@wraps(func)
def wrapper(*args, **kwargs):
start = time.time()
result = func(*args, **kwargs)
end = time.time()
print(end - start)
return result
return wrapper
In [2]:
@time_decorator
def test_func():
print('test')
In [3]:
test_func()