Created
September 17, 2019 18:23
-
-
Save TimothyLoyer/bf4a53bcd4142828e1d7140f22afe1f3 to your computer and use it in GitHub Desktop.
Print Runtime 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
| def print_runtime(func): | |
| """ | |
| Decorator to log the name and runtime in seconds for a callable. | |
| :param func: | |
| :return: | |
| """ | |
| def wrapper(*args, **kwargs): | |
| start = timer() | |
| value = func(*args, **kwargs) | |
| logger.info("{:0.5f}s - {}".format(timer() - start, func.__name__)) | |
| return value | |
| return wrapper |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment