codebanesr
Initial commit for HuggingFace Spaces deployment
b9e2109
Raw
History Blame Contribute Delete
907 Bytes
import time
import logging
from functools import wraps
logger = logging.getLogger(__name__)
def timing_decorator(func):
"""Decorator to log the execution time of a function."""
@wraps(func)
async def wrapper(*args, **kwargs):
start_time = time.time()
result = await func(*args, **kwargs)
elapsed_time = time.time() - start_time
logger.info(f"Function '{func.__name__}' completed in {elapsed_time:.2f} seconds")
return result
return wrapper
def sync_timing_decorator(func):
"""Decorator to log the execution time of a synchronous function."""
@wraps(func)
def wrapper(*args, **kwargs):
start_time = time.time()
result = func(*args, **kwargs)
elapsed_time = time.time() - start_time
logger.info(f"Function '{func.__name__}' completed in {elapsed_time:.2f} seconds")
return result
return wrapper