Clears caches during benchmark to ensure the same conditions for each test.

This commit is contained in:
Bertrand Bordage 2017-06-04 18:38:13 +02:00
parent da4e21b515
commit ce9ec0c0a1
2 changed files with 8 additions and 0 deletions

View File

@ -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:

View File

@ -23,6 +23,10 @@ Conditions
.. include:: ../benchmark/conditions.rst
Note that
`MySQLs query cache <http://dev.mysql.com/doc/refman/5.7/en/query-cache.html>`_
is active during the benchmark.
Database results
................