diff options
author | Mark Harfouche <mark.harfouche@gmail.com> | 2018-09-15 16:01:59 -0400 |
---|---|---|
committer | Mark Harfouche <mark.harfouche@gmail.com> | 2018-09-16 09:19:36 -0400 |
commit | 6ade16ee3f9cc0dd4f8486da6c247720f14c4e1e (patch) | |
tree | f0ba0f859d5ae46ca6a8381276a24649e8429749 /benchmarks | |
parent | ebf3648e8cdd6d6981a1b400da0ff26e580484e4 (diff) | |
download | numpy-6ade16ee3f9cc0dd4f8486da6c247720f14c4e1e.tar.gz |
Force pagefaults on other benchmarks too
Diffstat (limited to 'benchmarks')
-rw-r--r-- | benchmarks/benchmarks/bench_ma.py | 4 | ||||
-rw-r--r-- | benchmarks/benchmarks/bench_reduce.py | 6 | ||||
-rw-r--r-- | benchmarks/benchmarks/bench_shape_base.py | 8 |
3 files changed, 13 insertions, 5 deletions
diff --git a/benchmarks/benchmarks/bench_ma.py b/benchmarks/benchmarks/bench_ma.py index d313f01dc..aff78df0a 100644 --- a/benchmarks/benchmarks/bench_ma.py +++ b/benchmarks/benchmarks/bench_ma.py @@ -89,7 +89,9 @@ class Concatenate(Benchmark): ] def setup(self, mode, n): - normal = np.zeros((n, n), int) + # avoid np.zeros's lazy allocation that cause page faults during benchmark. + # np.fill will cause pagefaults to happen during setup. + normal = np.full((n, n), 0, int) unmasked = np.ma.zeros((n, n), int) masked = np.ma.array(normal, mask=True) diff --git a/benchmarks/benchmarks/bench_reduce.py b/benchmarks/benchmarks/bench_reduce.py index 353eb980c..ffc148cd2 100644 --- a/benchmarks/benchmarks/bench_reduce.py +++ b/benchmarks/benchmarks/bench_reduce.py @@ -29,8 +29,10 @@ class AddReduceSeparate(Benchmark): class AnyAll(Benchmark): def setup(self): - self.zeros = np.zeros(100000, bool) - self.ones = np.ones(100000, bool) + # avoid np.zeros's lazy allocation that would + # cause page faults during benchmark + self.zeros = np.full(100000, 0, bool) + self.ones = np.full(100000, 0, bool) def time_all_fast(self): self.zeros.all() diff --git a/benchmarks/benchmarks/bench_shape_base.py b/benchmarks/benchmarks/bench_shape_base.py index b05ea8263..6edad2ea3 100644 --- a/benchmarks/benchmarks/bench_shape_base.py +++ b/benchmarks/benchmarks/bench_shape_base.py @@ -23,7 +23,9 @@ class Block(Benchmark): self.four_1d = np.ones(6 * n) self.five_0d = np.ones(1 * n) self.six_1d = np.ones(5 * n) - self.zero_2d = np.zeros((2 * n, 6 * n)) + # avoid np.zeros's lazy allocation that might cause + # page faults during benchmark + self.zero_2d = np.full((2 * n, 6 * n), 0) self.one = np.ones(3 * n) self.two = 2 * np.ones((3, 3 * n)) @@ -31,7 +33,9 @@ class Block(Benchmark): self.four = 4 * np.ones(3 * n) self.five = 5 * np.ones(1 * n) self.six = 6 * np.ones(5 * n) - self.zero = np.zeros((2 * n, 6 * n)) + # avoid np.zeros's lazy allocation that might cause + # page faults during benchmark + self.zero = np.full((2 * n, 6 * n), 0) def time_block_simple_row_wise(self, n): np.block([self.a_2d, self.b_2d]) |