Created
March 10, 2016 04:44
-
-
Save etale-cohomology/7d39dc5a29e56a62798a to your computer and use it in GitHub Desktop.
This file contains 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
@contextlib.contextmanager # Create factory function for *with* context managers | |
def timeit(): | |
"""Time execution of code, based on time.clock(). Call using a *with* statement! | |
Examples: | |
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