Skip to content

Instantly share code, notes, and snippets.

@simahawk
Created October 4, 2016 14:09
Show Gist options
  • Save simahawk/6c470229c62c0738dc7c5fe995e8d001 to your computer and use it in GitHub Desktop.
Save simahawk/6c470229c62c0738dc7c5fe995e8d001 to your computer and use it in GitHub Desktop.
time your python functions
import time
def timeit(method):
"""Decorate methods to measure time."""
def timed(*args, **kw):
print 'START', method.__name__
ts = time.time()
result = method(*args, **kw)
te = time.time()
print 'STOP', method.__name__
print 'TIME %r (%r, %r) %2.2f sec' % \
(method.__name__, args, kw, te - ts)
return result
return timed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment