Skip to content

Instantly share code, notes, and snippets.

@sjl
Created December 26, 2011 20:15
Show Gist options
  • Save sjl/1522035 to your computer and use it in GitHub Desktop.
Save sjl/1522035 to your computer and use it in GitHub Desktop.
a usable time() in Python
>>> with time(): TeamMember.objects.count()
...
4886
0.00641298294067 seconds
from time import time as _t
import contextlib
@contextlib.contextmanager
def time():
t = _t()
yield
print _t() - t, 'seconds'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment