15 lines
325 B
Python
15 lines
325 B
Python
def timing(func):
|
|
def wrapper(*args, **kwargs):
|
|
import time
|
|
start_time = time.time()
|
|
result = func(*args, **kwargs)
|
|
print(f'Function {func.__name__} took {time.time() - start_time:.2f}s')
|
|
return result
|
|
return wrapper
|
|
|
|
|
|
@timing
|
|
def slow_f(n: int) -> int:
|
|
import time
|
|
time.sleep(2)
|
|
return n * 2
|