Skip to content

Instantly share code, notes, and snippets.

@northtree
Last active January 10, 2019 03:54
Show Gist options
  • Save northtree/ba122ab7e7d39ba9522d5d9577cb33ea to your computer and use it in GitHub Desktop.
Save northtree/ba122ab7e7d39ba9522d5d9577cb33ea to your computer and use it in GitHub Desktop.
Time Decorator #python #decorator
from time import time
def timeit(method):
def timed(*args, **kw):
time_start = time()
result = method(*args, **kw)
time_end = time()
time_diff = (time_end - time_start) * 1000
print('{}: {:2.2f} ms'.format(method.__name__, time_diff))
return result
return timed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment