Created
July 6, 2017 12:05
-
-
Save michaelosthege/dd291db70210e93644d9b8e5746f3ee4 to your computer and use it in GitHub Desktop.
Benchmarking helpers
This file contains hidden or 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
import time | |
class Measurement(object): | |
def __init__(self, name): | |
self.name = name | |
return | |
def __enter__(self): | |
self.t_start = time.time() | |
return | |
def __exit__(self, exc_type, exc_val, exc_tb): | |
t_end = time.time() | |
print("{} took {:.3f} seconds".format(self.name, t_end - self.t_start)) | |
return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment