Created
November 12, 2017 20:06
-
-
Save headsrooms/dd12b40121faecb51adc84c8d18d8ced to your computer and use it in GitHub Desktop.
Timer 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 functools import wraps | |
from time import time | |
def timeit(f): | |
@wraps(f) | |
def wrapper(*args, **kwargs): | |
start = time() | |
result = f(*args, **kwargs) | |
end = time() | |
print('Elapsed time: {}'.format(end - start)) | |
return result | |
return wrapper |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment