diff --git a/djangobench/benchmarks/raw_sql/__init__.py b/djangobench/benchmarks/raw_sql/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/djangobench/benchmarks/raw_sql/benchmark.py b/djangobench/benchmarks/raw_sql/benchmark.py new file mode 100644 index 0000000..e31b5a4 --- /dev/null +++ b/djangobench/benchmarks/raw_sql/benchmark.py @@ -0,0 +1,20 @@ +from djangobench.utils import run_benchmark +from raw_sql.models import OneField +from django.db import connection + +def benchmark(): + cursor = connection.cursor() + cursor.execute("select field1 from raw_sql_onefield") + list(cursor.fetchall()) + +def setup(): + for i in range(0, 10): + OneField(field1=i).save() + +run_benchmark( + benchmark, + setup=setup, + meta={ + 'description': 'A test for stressing direct SQL performance', + } +) diff --git a/djangobench/benchmarks/raw_sql/models.py b/djangobench/benchmarks/raw_sql/models.py new file mode 100644 index 0000000..f2dc1b4 --- /dev/null +++ b/djangobench/benchmarks/raw_sql/models.py @@ -0,0 +1,4 @@ +from django.db import models + +class OneField(models.Model): + field1 = models.CharField(max_length=100) diff --git a/djangobench/benchmarks/raw_sql/settings.py b/djangobench/benchmarks/raw_sql/settings.py new file mode 100644 index 0000000..b7d1ba5 --- /dev/null +++ b/djangobench/benchmarks/raw_sql/settings.py @@ -0,0 +1,3 @@ +from djangobench.base_settings import * + +INSTALLED_APPS = ['raw_sql']