advent-of-code/aoc_utils/decorators.py

13 lines
398 B
Python
Raw Permalink Normal View History

2023-12-23 15:28:25 +01:00
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