Last active
April 16, 2019 20:49
-
-
Save danemacaulay/be56437c47c02c98108594385c742c92 to your computer and use it in GitHub Desktop.
This file contains 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 | |
import time | |
import inspect | |
def timing(f): | |
@wraps(f) | |
def wrapper(*args, **kwargs): | |
module = inspect.getmodule(f).__name__ | |
start = time.time() | |
result = f(*args, **kwargs) | |
end = time.time() | |
elapsed = str(round(end - start, 4)) | |
print('Elapsed time: {}.{} {} seconds'.format(module, f.__name__, elapsed)) | |
return result | |
return wrapper |
Author
danemacaulay
commented
Apr 16, 2019
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment