import time
class print_time:
def __enter__(self):
self.time = time.time()
return self.time
def __exit__(self, type, value, traceback):
time_elapsed = time.time() - self.time
print time_elapsed
with print_time() as _:
do_something()
# '_' holds start time
Last active
August 29, 2015 14:22
-
-
Save hellpanderrr/96ca448054ad65ca293f to your computer and use it in GitHub Desktop.
Print time needed for code execution
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment