Skip to content

Instantly share code, notes, and snippets.

@jeakwon
Created May 8, 2019 03:49
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 jeakwon/d88f4501c0407b0a498396b341d5de96 to your computer and use it in GitHub Desktop.
Save jeakwon/d88f4501c0407b0a498396b341d5de96 to your computer and use it in GitHub Desktop.
runtime_decorator
def runtime(func):
@wraps(func)
def decorated(*args, **kwargs):
# Decorate front of func
before = time.time()
output = func(*args, **kwargs)
# Decorate back of func
after = time.time()
print('Elapsed time: {}'.format(after-before))
return output
return decorated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment