lalala33rfs

Untitled

Nov 17th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.27 KB | None | 0 0
  1. from time import perf_counter
  2.  
  3.  
  4. class Timer:
  5.     def __enter__(self):
  6.         if not hasattr(self, 'start_time'):
  7.             self.start = perf_counter()
  8.  
  9.     def __exit__(self, exc_type, exc_val, exc_tb):
  10.         print(perf_counter() - self.start)
  11.         return True
Add Comment
Please, Sign In to add comment