Skip to content

Instantly share code, notes, and snippets.

@mackee
Created October 14, 2011 08:24
Show Gist options
  • Save mackee/1286555 to your computer and use it in GitHub Desktop.
Save mackee/1286555 to your computer and use it in GitHub Desktop.
stopwatch decorater
import time
def stopwatch(self, wrapped):
def _wrapper(*args, **kwargs):
tic = time.time()
result = wrapped(*args, **kwargs)
toc = time.time()
doc = str(wrapped.__doc__).split("\n")[0]
print("[%s] %f[sec]" % (doc, toc - tic))
return result
return _wrapper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment