diff options
author | Mark Harfouche <mark.harfouche@gmail.com> | 2018-09-15 15:50:55 -0400 |
---|---|---|
committer | Mark Harfouche <mark.harfouche@gmail.com> | 2018-09-16 09:13:24 -0400 |
commit | ebf3648e8cdd6d6981a1b400da0ff26e580484e4 (patch) | |
tree | 1d21f3f1e19a5c1cce6ca980569be4897649dd7f /benchmarks | |
parent | 58da56876328e51473ebd4c5ce819262621d5278 (diff) | |
download | numpy-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.py | 5 |
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) |