| 1 | Running Django's own testsuite:
|
|---|
| 2 | #./runtests.py --settings=test_sqlite --verbosity=0
|
|---|
| 3 | and then alternating between trunk and patched version
|
|---|
| 4 |
|
|---|
| 5 | Switched to branch 'master'
|
|---|
| 6 | Ran 4218 tests in 590.286s
|
|---|
| 7 |
|
|---|
| 8 | Switched to branch 'add_q_further'
|
|---|
| 9 | Ran 4218 tests in 541.701s
|
|---|
| 10 |
|
|---|
| 11 | Switched to branch 'master'
|
|---|
| 12 | Ran 4218 tests in 583.265s
|
|---|
| 13 |
|
|---|
| 14 | Switched to branch 'add_q_further'
|
|---|
| 15 | Ran 4218 tests in 562.066s
|
|---|
| 16 |
|
|---|
| 17 | Switched to branch 'master'
|
|---|
| 18 | Ran 4218 tests in 644.779s
|
|---|
| 19 |
|
|---|
| 20 | Switched to branch 'add_q_further'
|
|---|
| 21 | Ran 4218 tests in 530.566s
|
|---|
| 22 |
|
|---|
| 23 | Switched to branch 'master'
|
|---|
| 24 | Ran 4218 tests in 592.954s
|
|---|
| 25 |
|
|---|
| 26 | Switched to branch 'add_q_further'
|
|---|
| 27 | Ran 4218 tests in 539.268s
|
|---|
| 28 |
|
|---|
| 29 | Master Total: 2409
|
|---|
| 30 | Where Refactor: 2172
|
|---|
| 31 |
|
|---|
| 32 | Speedup about 10%
|
|---|
| 33 |
|
|---|
| 34 | A couple of test with postgresql and the following model:
|
|---|
| 35 |
|
|---|
| 36 | class User(models.Model):
|
|---|
| 37 | email = models.TextField()
|
|---|
| 38 |
|
|---|
| 39 | The test file is as follows, you need to do some application setup:
|
|---|
| 40 |
|
|---|
| 41 | import settings
|
|---|
| 42 | from django.core.management import setup_environ
|
|---|
| 43 | setup_environ(settings)
|
|---|
| 44 |
|
|---|
| 45 | from test_models.models import User
|
|---|
| 46 | from datetime import datetime
|
|---|
| 47 | from django.db import transaction
|
|---|
| 48 |
|
|---|
| 49 | User.objects.create(pk=1, email='foo@bar.com')
|
|---|
| 50 |
|
|---|
| 51 | #Test 1
|
|---|
| 52 | start = datetime.now()
|
|---|
| 53 | for i in range(0, 1000):
|
|---|
| 54 | User.objects.filter(pk=1)
|
|---|
| 55 | print datetime.now() - start
|
|---|
| 56 |
|
|---|
| 57 | #Test 2
|
|---|
| 58 | qs = User.objects.all()
|
|---|
| 59 | start = datetime.now()
|
|---|
| 60 | for i in range(0, 200):
|
|---|
| 61 | qs = qs.filter(pk=i)
|
|---|
| 62 | print datetime.now() - start
|
|---|
| 63 |
|
|---|
| 64 | # Test3
|
|---|
| 65 | qs = User.objects.all()
|
|---|
| 66 | @transaction.commit_on_success
|
|---|
| 67 | def managed():
|
|---|
| 68 | start = datetime.now()
|
|---|
| 69 | for i in range(0, 1000):
|
|---|
| 70 | obj = User.objects.get(pk=1)
|
|---|
| 71 | obj.save()
|
|---|
| 72 | print datetime.now() - start
|
|---|
| 73 | managed()
|
|---|
| 74 |
|
|---|
| 75 |
|
|---|
| 76 |
|
|---|
| 77 |
|
|---|
| 78 |
|
|---|