summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBertrand Bordage <bordage.bertrand@gmail.com>2017-06-04 16:38:13 (GMT)
committerBertrand Bordage <bordage.bertrand@gmail.com>2017-06-04 16:38:13 (GMT)
commitce9ec0c0a1e21dcf4d0cb5f2cdf3e95456a5f3c1 (patch)
treef251f312892081dcc5157bce2dc67a572894f367
parentda4e21b5156759fa117f516c9dfd919061b71220 (diff)
downloaddjango-cachalot-ce9ec0c0a1e21dcf4d0cb5f2cdf3e95456a5f3c1.zip
django-cachalot-ce9ec0c0a1e21dcf4d0cb5f2cdf3e95456a5f3c1.tar.gz
django-cachalot-ce9ec0c0a1e21dcf4d0cb5f2cdf3e95456a5f3c1.tar.bz2
Clears caches during benchmark to ensure the same conditions for each test.
-rwxr-xr-xbenchmark.py4
-rw-r--r--docs/benchmark.rst4
2 files changed, 8 insertions, 0 deletions
diff --git a/benchmark.py b/benchmark.py
index fe14194..e157672 100755
--- a/benchmark.py
+++ b/benchmark.py
@@ -161,6 +161,10 @@ class Benchmark(object):
'cache': self.cache_name})
def benchmark(self, query_str, to_list=True, num_queries=1):
+ # Clears the cache before a single benchmark to ensure the same
+ # conditions across single benchmarks.
+ caches[settings.CACHALOT_CACHE].clear()
+
self.query_name = query_str
query_str = 'Test.objects.using(using)' + query_str
if to_list:
diff --git a/docs/benchmark.rst b/docs/benchmark.rst
index 5e77f80..ac0597b 100644
--- a/docs/benchmark.rst
+++ b/docs/benchmark.rst
@@ -23,6 +23,10 @@ Conditions
.. include:: ../benchmark/conditions.rst
+Note that
+`MySQL’s query cache <http://dev.mysql.com/doc/refman/5.7/en/query-cache.html>`_
+is active during the benchmark.
+
Database results
................