Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
def logging_time(func):
def logger(*args, **kwargs):
start = time.time()
returned = func(*args, **kwargs)
end = time.time()
print(f"Calling {func.__name__} time: {end - start:.5f}")
return returned
return logger
@logging_time
def calculate_sum(n):
return sum(range(n+1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment