diff options
| author | Matti Picus <matti.picus@gmail.com> | 2018-09-04 10:57:55 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-09-04 10:57:55 +0300 |
| commit | 058851c5cfc98f50f11237b1c13d77cfd1f40475 (patch) | |
| tree | 76c0582968547cfb69e533b020c1d745acbe2bc7 | |
| parent | fe3412fde8990ff08405f3324d309e521aff1d7d (diff) | |
| parent | a798ec780907a9656535b71709c7231b032cee6e (diff) | |
| download | numpy-058851c5cfc98f50f11237b1c13d77cfd1f40475.tar.gz | |
Merge pull request #11874 from pv/bench-slow-setup
BENCH: split out slow setup method in bench_shape_base.Block
| -rw-r--r-- | benchmarks/benchmarks/bench_shape_base.py | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/benchmarks/benchmarks/bench_shape_base.py b/benchmarks/benchmarks/bench_shape_base.py index 9d0f0ae04..b05ea8263 100644 --- a/benchmarks/benchmarks/bench_shape_base.py +++ b/benchmarks/benchmarks/bench_shape_base.py @@ -33,18 +33,6 @@ class Block(Benchmark): self.six = 6 * np.ones(5 * n) self.zero = np.zeros((2 * n, 6 * n)) - self.a000 = np.ones((2 * n, 2 * n, 2 * n), int) * 1 - - self.a100 = np.ones((3 * n, 2 * n, 2 * n), int) * 2 - self.a010 = np.ones((2 * n, 3 * n, 2 * n), int) * 3 - self.a001 = np.ones((2 * n, 2 * n, 3 * n), int) * 4 - - self.a011 = np.ones((2 * n, 3 * n, 3 * n), int) * 5 - self.a101 = np.ones((3 * n, 2 * n, 3 * n), int) * 6 - self.a110 = np.ones((3 * n, 3 * n, 2 * n), int) * 7 - - self.a111 = np.ones((3 * n, 3 * n, 3 * n), int) * 8 - def time_block_simple_row_wise(self, n): np.block([self.a_2d, self.b_2d]) @@ -72,6 +60,29 @@ class Block(Benchmark): [self.zero] ]) + def time_no_lists(self, n): + np.block(1) + np.block(np.eye(3 * n)) + + +class Block3D(Benchmark): + params = [1, 10, 100] + param_names = ['size'] + + def setup(self, n): + # Slow setup method: hence separated from the others above + self.a000 = np.ones((2 * n, 2 * n, 2 * n), int) * 1 + + self.a100 = np.ones((3 * n, 2 * n, 2 * n), int) * 2 + self.a010 = np.ones((2 * n, 3 * n, 2 * n), int) * 3 + self.a001 = np.ones((2 * n, 2 * n, 3 * n), int) * 4 + + self.a011 = np.ones((2 * n, 3 * n, 3 * n), int) * 5 + self.a101 = np.ones((3 * n, 2 * n, 3 * n), int) * 6 + self.a110 = np.ones((3 * n, 3 * n, 2 * n), int) * 7 + + self.a111 = np.ones((3 * n, 3 * n, 3 * n), int) * 8 + def time_3d(self, n): np.block([ [ @@ -84,6 +95,5 @@ class Block(Benchmark): ] ]) - def time_no_lists(self, n): - np.block(1) - np.block(np.eye(3 * n)) + # Retain old benchmark name for backward compat + time_3d.benchmark_name = "bench_shape_base.Block.time_3d" |
