summaryrefslogtreecommitdiff
path: root/benchmarks
diff options
context:
space:
mode:
authorMark Harfouche <mark.harfouche@gmail.com>2018-09-15 15:50:55 -0400
committerMark Harfouche <mark.harfouche@gmail.com>2018-09-16 09:13:24 -0400
commitebf3648e8cdd6d6981a1b400da0ff26e580484e4 (patch)
tree1d21f3f1e19a5c1cce6ca980569be4897649dd7f /benchmarks
parent58da56876328e51473ebd4c5ce819262621d5278 (diff)
downloadnumpy-ebf3648e8cdd6d6981a1b400da0ff26e580484e4.tar.gz
MAINT: np.pad Explicitely cause pagefaults to happen before starting the benchmark
Diffstat (limited to 'benchmarks')
-rw-r--r--benchmarks/benchmarks/bench_lib.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/benchmarks/benchmarks/bench_lib.py b/benchmarks/benchmarks/bench_lib.py
index 83f26c9d1..e6c91a27c 100644
--- a/benchmarks/benchmarks/bench_lib.py
+++ b/benchmarks/benchmarks/bench_lib.py
@@ -19,7 +19,10 @@ class Pad(Benchmark):
]
def setup(self, shape, pad_width, mode):
- self.array = np.empty(shape)
+ # avoid np.zeros or np.empty's lazy allocation.
+ # np.full causes pagefaults to occur during setup
+ # instead of during the benchmark
+ self.array = np.full(shape, 0)
def time_pad(self, shape, pad_width, mode):
np.pad(self.array, pad_width, mode)