import time
import functools
def time_it(func):
@functools.wraps(func)
def wrapper(*args, **kwargs):
start = time.perf_counter() # Start Time
result = func(*args, **kwargs)
end = time.perf_counter() # End Time
print(f"function {func.__name__} ran in {end - start:0.4f} seconds")
return result
return wrapper
@time_it
def some_function(sec: int):
time.sleep(sec)
if __name__ == "__main__":
some_function(5)