diff options
author | Mark Harfouche <mark.harfouche@gmail.com> | 2018-09-19 10:48:46 -0400 |
---|---|---|
committer | Mark Harfouche <mark.harfouche@gmail.com> | 2018-09-20 13:20:05 -0400 |
commit | 2ccfc32ea1de8656c6c780ad52aa7315294a5151 (patch) | |
tree | 01f82c18bbfd41553dcc1bc1a30d5c03a63e4c02 /benchmarks | |
parent | 4b62f09769e38902d70b9227ac2988047c4e189d (diff) | |
download | numpy-2ccfc32ea1de8656c6c780ad52aa7315294a5151.tar.gz |
BENCH: Add a relatable 2D benchmark for block
Diffstat (limited to 'benchmarks')
-rw-r--r-- | benchmarks/benchmarks/bench_shape_base.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/benchmarks/benchmarks/bench_shape_base.py b/benchmarks/benchmarks/bench_shape_base.py index b05ea8263..716d1f9b5 100644 --- a/benchmarks/benchmarks/bench_shape_base.py +++ b/benchmarks/benchmarks/bench_shape_base.py @@ -65,6 +65,24 @@ class Block(Benchmark): np.block(np.eye(3 * n)) +class Block2D(Benchmark): + params = [[(16, 16), (32, 32), (64, 64), (128, 128), (256, 256), (512, 512), (1024, 1024)], + ['uint8', 'uint16', 'uint32', 'uint64'], + [(2, 2), (4, 4)]] + param_names = ['shape', 'dtype', 'n_chunks'] + + def setup(self, shape, dtype, n_chunks): + + self.block_list = [ + [np.full(shape=[s//n_chunk for s, n_chunk in zip(shape, n_chunks)], + fill_value=1, dtype=dtype) for _ in range(n_chunks[1])] + for _ in range(n_chunks[0]) + ] + + def time_block2d(self, shape, dtype, n_chunks): + np.block(self.block_list) + + class Block3D(Benchmark): params = [1, 10, 100] param_names = ['size'] |