Skip to content

Instantly share code, notes, and snippets.

@mrchilds
Created September 24, 2012 13:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrchilds/3776003 to your computer and use it in GitHub Desktop.
Save mrchilds/3776003 to your computer and use it in GitHub Desktop.
Django Performance Fact Finding
Very quick way to get some timing info...
import time
class Timer():
def __enter__(self): self.start = time.time()
def __exit__(self, *args): print time.time() - self.start
with Timer():
some_code()
#Count and show queries (great for ajax requests)
from django.db import connection
x = 0
for query in connection.queries:
print query
x += 1
print x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment