Skip to content

Instantly share code, notes, and snippets.

@hungyiwu
hungyiwu / timer_class.py
Created July 15, 2020 02:38 — forked from DahlitzFlorian/timer_class.py
Article: How To Create Your Own Timing Context Manager
from time import time
class Timer(object):
def __init__(self, description):
self.description = description
def __enter__(self):
self.start = time()
def __exit__(self, type, value, traceback):
self.end = time()