-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added 4 new benchmarks - query_all, query_all_multifield, query_raw a…
…nd query_raw_deferred. These were created by akaariai for Django tickets #14697 and #14700
- Loading branch information
1 parent
c366752
commit 60fea38
Showing
16 changed files
with
132 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from djangobench.utils import run_benchmark | ||
from query_all.models import Book | ||
|
||
def benchmark(): | ||
list(Book.objects.iterator()) | ||
|
||
def setup(): | ||
for i in range(0, 3000): | ||
Book(pk=i,title='foobar_%s' % i ).save() | ||
|
||
run_benchmark( | ||
benchmark, | ||
setup=setup, | ||
meta = { | ||
'description': 'A simple Model.objects.iterator() call for large number of objects.', | ||
} | ||
) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from django.db import models | ||
|
||
class Book(models.Model): | ||
title = models.CharField(max_length=100) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from djangobench.base_settings import * | ||
|
||
INSTALLED_APPS = ['query_all'] |
Empty file.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from djangobench.utils import run_benchmark | ||
from query_all_multifield.models import MultiField | ||
|
||
def benchmark(): | ||
list(MultiField.objects.iterator()) | ||
|
||
def setup(): | ||
for i in range(0, 3000): | ||
kwargs = {} | ||
for j in range(1, 11): | ||
kwargs['field%s' % j] = 'foobar_%s_%s' % (i, j) | ||
MultiField(**kwargs).save() | ||
|
||
run_benchmark( | ||
benchmark, | ||
setup=setup, | ||
meta = { | ||
'description': 'A simple Model.objects.iterator() call for large number of objects and large number of fields.', | ||
} | ||
) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from django.db import models | ||
|
||
class MultiField(models.Model): | ||
field1 = models.CharField(max_length=100) | ||
field2 = models.CharField(max_length=100) | ||
field3 = models.CharField(max_length=100) | ||
field4 = models.CharField(max_length=100) | ||
field5 = models.CharField(max_length=100) | ||
field6 = models.CharField(max_length=100) | ||
field7 = models.CharField(max_length=100) | ||
field8 = models.CharField(max_length=100) | ||
field9 = models.CharField(max_length=100) | ||
field10 = models.CharField(max_length=100) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from djangobench.base_settings import * | ||
|
||
INSTALLED_APPS = ['query_all_multifield'] |
Empty file.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from djangobench.utils import run_benchmark | ||
from query_raw.models import MultiField | ||
|
||
def benchmark(): | ||
list(MultiField.objects.raw('select * from query_raw_multifield')) | ||
|
||
def setup(): | ||
for i in range(0, 1000): | ||
kwargs = {} | ||
for j in range(1, 11): | ||
kwargs['field%s' % j] = 'foobar_%s_%s' % (i, j) | ||
MultiField(**kwargs).save() | ||
|
||
run_benchmark( | ||
benchmark, | ||
setup=setup, | ||
meta = { | ||
'description': 'A test for fetching large number of objects by Model.objects.all()', | ||
} | ||
) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from django.db import models | ||
|
||
class MultiField(models.Model): | ||
field1 = models.CharField(max_length=100) | ||
field2 = models.CharField(max_length=100) | ||
field3 = models.CharField(max_length=100) | ||
field4 = models.CharField(max_length=100) | ||
field5 = models.CharField(max_length=100) | ||
field6 = models.CharField(max_length=100) | ||
field7 = models.CharField(max_length=100) | ||
field8 = models.CharField(max_length=100) | ||
field9 = models.CharField(max_length=100) | ||
field10 = models.CharField(max_length=100) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from djangobench.base_settings import * | ||
|
||
INSTALLED_APPS = ['query_raw'] |
Empty file.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from djangobench.utils import run_benchmark | ||
from query_raw_deferred.models import MultiField | ||
|
||
def benchmark(): | ||
list(MultiField.objects.raw('select id from query_raw_deferred_multifield')) | ||
|
||
def setup(): | ||
for i in range(0, 1000): | ||
kwargs = {} | ||
for j in range(1, 11): | ||
kwargs['field%s' % j] = 'foobar_%s_%s' % (i, j) | ||
MultiField(**kwargs).save() | ||
|
||
run_benchmark( | ||
benchmark, | ||
setup=setup, | ||
meta = { | ||
'description': 'A test for fetching large number of objects by Model.objects.all() with deferred fields.', | ||
} | ||
) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from django.db import models | ||
|
||
class MultiField(models.Model): | ||
field1 = models.CharField(max_length=100) | ||
field2 = models.CharField(max_length=100) | ||
field3 = models.CharField(max_length=100) | ||
field4 = models.CharField(max_length=100) | ||
field5 = models.CharField(max_length=100) | ||
field6 = models.CharField(max_length=100) | ||
field7 = models.CharField(max_length=100) | ||
field8 = models.CharField(max_length=100) | ||
field9 = models.CharField(max_length=100) | ||
field10 = models.CharField(max_length=100) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from djangobench.base_settings import * | ||
|
||
INSTALLED_APPS = ['query_raw_deferred'] |