From ce9ec0c0a1e21dcf4d0cb5f2cdf3e95456a5f3c1 Mon Sep 17 00:00:00 2001 From: Bertrand Bordage Date: Sun, 4 Jun 2017 18:38:13 +0200 Subject: [PATCH] Clears caches during benchmark to ensure the same conditions for each test. --- benchmark.py | 4 ++++ docs/benchmark.rst | 4 ++++ 2 files changed, 8 insertions(+) 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 `_ +is active during the benchmark. + Database results ................