Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from time import perf_counter
- class Timer:
- def __enter__(self):
- if not hasattr(self, 'start_time'):
- self.start = perf_counter()
- def __exit__(self, exc_type, exc_val, exc_tb):
- print(perf_counter() - self.start)
- return True
Add Comment
Please, Sign In to add comment