Skip to content

Instantly share code, notes, and snippets.

@internetimagery
Last active October 17, 2015 12:02
Show Gist options
  • Select an option

  • Save internetimagery/41c2f2c6d421e7983f06 to your computer and use it in GitHub Desktop.

Select an option

Save internetimagery/41c2f2c6d421e7983f06 to your computer and use it in GitHub Desktop.
Simple code timer.
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