Created
May 8, 2019 03:49
-
-
Save jeakwon/d88f4501c0407b0a498396b341d5de96 to your computer and use it in GitHub Desktop.
runtime_decorator
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
def runtime(func): | |
@wraps(func) | |
def decorated(*args, **kwargs): | |
# Decorate front of func | |
before = time.time() | |
output = func(*args, **kwargs) | |
# Decorate back of func | |
after = time.time() | |
print('Elapsed time: {}'.format(after-before)) | |
return output | |
return decorated |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment