From 6a4858cc1b416bbff014d520a2725cbc25e7d7c4 Mon Sep 17 00:00:00 2001 From: Julian Taylor Date: Sat, 25 Mar 2017 14:38:24 +0100 Subject: BENCH: use initialized memory for count_nonzero benchmark For the bool case uninitialized memory can randomly go into the slow path handling values different than 0 or 1. --- benchmarks/benchmarks/bench_core.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'benchmarks') diff --git a/benchmarks/benchmarks/bench_core.py b/benchmarks/benchmarks/bench_core.py index a4e3152ea..bab0ff4e6 100644 --- a/benchmarks/benchmarks/bench_core.py +++ b/benchmarks/benchmarks/bench_core.py @@ -137,8 +137,8 @@ class CountNonzero(Benchmark): ] def setup(self, numaxes, size, dtype): - self.x = np.empty(shape=( - numaxes, size), dtype=dtype) + self.x = np.arange(numaxes * size).reshape(numaxes, size) + self.x = (self.x % 3).astype(dtype) def time_count_nonzero(self, numaxes, size, dtype): np.count_nonzero(self.x) -- cgit v1.2.3