Skip to content

Instantly share code, notes, and snippets.

@ycui1
Created October 11, 2021 00:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ycui1/59b608f8ffe4780860cca66cdc0aeadd to your computer and use it in GitHub Desktop.
Save ycui1/59b608f8ffe4780860cca66cdc0aeadd to your computer and use it in GitHub Desktop.
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