QuaPy/KDEy/utils.py

12 lines
479 B
Python

import time
from functools import wraps
def measuretime(func):
@wraps(func)
def wrapper(*args, **kwargs):
start_time = time.time() # inicia el contador de tiempo
result = func(*args, **kwargs) # ejecuta la función original
end_time = time.time() # finaliza el contador de tiempo
time_it_took = end_time - start_time # calcula el tiempo total
return result, time_it_took # devuelve el resultado y el tiempo
return wrapper