summaryrefslogtreecommitdiff
path: root/benchmarks
diff options
context:
space:
mode:
authorJulian Taylor <jtaylor.debian@googlemail.com>2017-03-25 14:38:24 +0100
committerJulian Taylor <jtaylor.debian@googlemail.com>2017-03-25 14:38:24 +0100
commit6a4858cc1b416bbff014d520a2725cbc25e7d7c4 (patch)
treefe83bee905677e4bae4610eb6df055b94176544c /benchmarks
parenta7ed83f6d9e5e8f5a024dfe2d42ad290d79422b1 (diff)
downloadpython-numpy-6a4858cc1b416bbff014d520a2725cbc25e7d7c4.tar.gz
python-numpy-6a4858cc1b416bbff014d520a2725cbc25e7d7c4.tar.bz2
python-numpy-6a4858cc1b416bbff014d520a2725cbc25e7d7c4.zip
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.
Diffstat (limited to 'benchmarks')
-rw-r--r--benchmarks/benchmarks/bench_core.py4
1 files changed, 2 insertions, 2 deletions
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)