Skip to content

Instantly share code, notes, and snippets.

@michaelosthege
Created July 6, 2017 12:05
Show Gist options
  • Save michaelosthege/dd291db70210e93644d9b8e5746f3ee4 to your computer and use it in GitHub Desktop.
Save michaelosthege/dd291db70210e93644d9b8e5746f3ee4 to your computer and use it in GitHub Desktop.
Benchmarking helpers
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