Created
September 24, 2012 13:40
-
-
Save mrchilds/3776003 to your computer and use it in GitHub Desktop.
Django Performance Fact Finding
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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