13 lines
398 B
Python
13 lines
398 B
Python
from functools import cache, wraps
|
|
import time
|
|
|
|
def timeit(func):
|
|
@wraps(func)
|
|
def timeit_wrapper(*args, **kwargs):
|
|
start_time = time.perf_counter()
|
|
result = func(*args, **kwargs)
|
|
end_time = time.perf_counter()
|
|
total_time = end_time - start_time
|
|
print(f'===== {func.__name__}: {total_time:.4f}s =====')
|
|
return result
|
|
return timeit_wrapper |