Last active
January 10, 2019 03:54
-
-
Save northtree/ba122ab7e7d39ba9522d5d9577cb33ea to your computer and use it in GitHub Desktop.
Time Decorator #python #decorator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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