Last active
October 17, 2015 12:02
-
-
Save internetimagery/41c2f2c6d421e7983f06 to your computer and use it in GitHub Desktop.
Simple code timer.
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
| class Timer(object): | |
| verbose = False | |
| def __init__(s, name): | |
| from time import time | |
| s.time = time | |
| s.name = name | |
| def __enter__(s): s.start = s.time() | |
| def __exit__(s, *err): | |
| if s.verbose: print "%s...\t\tElapsed time: %sms." % (s.name, (s.time() - s.start) * 1000) | |
| Timer.verbose = True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment