Created
July 2, 2010 18:35
-
-
Save ericflo/461715 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
import time | |
from contextlib import contextmanager | |
@contextmanager | |
def easyprofile(msg): | |
before = time.time() | |
yield | |
print '%s took %0.2fsec' % (msg, time.time() - before) | |
if __name__ == '__main__': | |
with easyprofile('Executing an expensive query'): | |
results = get_expensive_data() | |
# Do something with the results |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment