Skip to content

Instantly share code, notes, and snippets.

@discort
Created July 20, 2021 09:59
Show Gist options
  • Save discort/5657788cb279b07749dc6d62a79f102d to your computer and use it in GitHub Desktop.
Save discort/5657788cb279b07749dc6d62a79f102d to your computer and use it in GitHub Desktop.
Timing decorator
# https://stackoverflow.com/a/27737385/3960038
from functools import wraps
from time import time
def timing(f):
@wraps(f)
def wrap(*args, **kw):
ts = time()
result = f(*args, **kw)
te = time()
print('func:%r took: %2.4f sec' % (f.__name__, te-ts))
return result
return wrap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment