mirror of
https://github.com/tcsenpai/agenticSeek.git
synced 2025-06-03 01:30:11 +00:00
17 lines
467 B
Python
17 lines
467 B
Python
|
|
def timer_decorator(func):
|
|
"""
|
|
Decorator to measure the execution time of a function.
|
|
Usage:
|
|
@timer_decorator
|
|
def my_function():
|
|
# code to execute
|
|
"""
|
|
from time import time
|
|
def wrapper(*args, **kwargs):
|
|
start_time = time()
|
|
result = func(*args, **kwargs)
|
|
end_time = time()
|
|
print(f"\n{func.__name__} took {end_time - start_time:.2f} seconds to execute\n")
|
|
return result
|
|
return wrapper |