Skip to content

Commit

Permalink
Merge pull request #6 from jphalip/master
Browse files Browse the repository at this point in the history
A few fixes made by Luke and I to make it work in Django > 1.3. Luke also tweaked/added a few benchmarks.
  • Loading branch information
jacobian committed Dec 7, 2011
2 parents 9e04e3a + 9eda1a4 commit 0c9e0fb
Show file tree
Hide file tree
Showing 5 changed files with 1,495 additions and 9 deletions.
7 changes: 7 additions & 0 deletions djangobench/base_settings.py
@@ -1,2 +1,9 @@
DATABASE_ENGINE = 'sqlite3'
DATABASE_NAME = ':memory:'

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': ':memory:'
},
}
3 changes: 2 additions & 1 deletion djangobench/benchmarks/default_middleware/benchmark.py
@@ -1,6 +1,6 @@
from time import time

from django.test.client import Client
from django.test.client import Client, FakePayload
from django.conf import global_settings
from django.conf import settings
from django.core.handlers.wsgi import WSGIRequest
Expand Down Expand Up @@ -41,6 +41,7 @@ def request(self, **request):
'SERVER_NAME': 'testserver',
'SERVER_PORT': 80,
'SERVER_PROTOCOL': 'HTTP/1.1',
'wsgi.input': FakePayload(''),
}
environ.update(self.defaults)
environ.update(request)
Expand Down
9 changes: 8 additions & 1 deletion djangobench/benchmarks/query_get/benchmark.py
Expand Up @@ -2,7 +2,14 @@
from query_get.models import Book

def benchmark():
Book.objects.get(id=1)
for i in range(0, 30):
# This will succeed
Book.objects.get(id=1)
try:
# This will fail, due to too many objects
Book.objects.get()
except:
pass

run_benchmark(
benchmark,
Expand Down
3 changes: 2 additions & 1 deletion djangobench/benchmarks/query_select_related/benchmark.py
Expand Up @@ -2,7 +2,8 @@
from query_select_related.models import Book

def benchmark():
list(Book.objects.select_related())
for i in xrange(20):
list(Book.objects.select_related('author'))

run_benchmark(
benchmark,
Expand Down

0 comments on commit 0c9e0fb

Please sign in to comment.