py-code-analyzer / utils.py
cyyeh's picture
format
c98d640
raw
history blame contribute delete
449 Bytes
import time
def conditonal_decorator(dec, condition):
def decorator(func):
if not condition:
return func
return dec(func)
return decorator
def time_function(f):
def wrapper(*args, **kwargs):
begin = time.time()
result = f(*args, **kwargs)
end = time.time()
print(f"function {f.__name__} took: {end - begin} seconds to execute.")
return result
return wrapper