Skip to content

Instantly share code, notes, and snippets.

View willmcgugan's full-sized avatar
🏠
Working from home

Will McGugan willmcgugan

🏠
Working from home
View GitHub Profile
@willmcgugan
willmcgugan / gist:2948552
Created June 18, 2012 14:08
Timer decorator
from contextlib import contextmanager
from time import time, mktime
from datetime import datetime
@contextmanager
def timer(msg="elapsed", ms=False, write_file=None):
now = datetime.now()
start = time()
yield
taken = (time() - start)