Last active
December 10, 2015 21:08
-
-
Save alonho/4493079 to your computer and use it in GitHub Desktop.
a timed contextmanager for easy benchmarking.
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 Framework.Log.Log import logger | |
from contextlib import contextmanager | |
from time import time | |
@contextmanager | |
def timed(message): | |
'''' | |
with timed('testing division'): | |
4 / 2 | |
'''' | |
stime = time() | |
yield | |
logger.info("{} took {}".format(message, time() - stime)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment