Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
@contextlib.contextmanager # Create factory function for *with* context managers
def timeit():
"""Time execution of code, based on time.clock(). Call using a *with* statement!
with timeit():
a @ a
start = time.clock()
yield # The decorated func must return a generator-iterator
print('Operation took: %0.6f seconds!' % (time.clock() - start))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment