10000 BENCH: Add a relatable 2D benchmark for block · numpy/numpy@2ccfc32 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2ccfc32

Browse files
committed
BENCH: Add a relatable 2D benchmark for block
1 parent 4b62f09 commit 2ccfc32

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

benchmarks/benchmarks/bench_shape_base.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,24 @@ def time_no_lists(self, n):
6565
np.block(np.eye(3 * n))
6666

6767

68+
class Block2D(Benchmark):
69+
params = [[(16, 16), (32, 32), (64, 64), (128, 128), (256, 256), (512, 512), (1024, 1024)],
70+
['uint8', 'uint16', 'uint32', 'uint64'],
71+
[(2, 2), (4, 4)]]
72+
param_names = ['shape', 'dtype', 'n_chunks']
73+
74+
def setup(self, shape, dtype, n_chunks):
75+
76+
self.block_list = [
77+
[np.full(shape=[s//n_chunk for s, n_chunk in zip(shape, n_chunks)],
78+
fill_value=1, dtype=dtype) for _ in range(n_chunks[1])]
79+
for _ in range(n_chunks[0])
80+
]
81+
82+
def time_block2d(self, shape, dtype, n_chunks):
83+
np.block(self.block_list)
84+
85+
6886
class Block3D(Benchmark):
6987
params = [1, 10, 100]
7088
param_names = ['size']

0 commit comments

Comments
 (0)
0