@@ -88,10 +88,18 @@ def time_block2d(self, shape, dtype, n_chunks):
88
88
89
89
90
90
class Block3D (Benchmark ):
91
- params = [1 , 10 , 100 ]
92
- param_names = ['size' ]
93
-
94
- def setup (self , n ):
91
+ """This benchmark concatenates an array of size ``(5n)^3``"""
92
+ # Having copy as a `mode` of the block3D
93
+ # allows us to directly compare the benchmark of block
94
+ # to that of a direct memory copy into new buffers with
95
+ # the ASV framework.
96
+ # block and copy will be plotted on the same graph
97
+ # as opposed to being displayed as separate benchmarks
98
+ params = [[1 , 10 , 100 ],
99
+ ['block' , 'copy' ]]
100
+ param_names = ['n' , 'mode' ]
101
+
102
+ def setup (self , n , mode ):
95
103
# Slow setup method: hence separated from the others above
96
104
self .a000 = np .ones ((2 * n , 2 * n , 2 * n ), int ) * 1
97
105
@@ -105,8 +113,7 @@ def setup(self, n):
105
113
106
114
self .a111 = np .ones ((3 * n , 3 * n , 3 * n ), int ) * 8
107
115
108
- def time_3d (self , n ):
109
- np .block ([
116
+ self .block = [
110
117
[
111
118
[self .a000 , self .a001 ],
112
119
[self .a010 , self .a011 ],
@@ -115,7 +122,17 @@ def time_3d(self, n):
115
122
[self .a100 , self .a101 ],
116
123
[self .a110 , self .a111 ],
117
124
]
118
- ])
125
+ ]
126
+ self .arr_list = [a
127
+ for two_d in self .block
128
+ for one_d in two_d
129
+ for a in one_d ]
130
+
131
+ def time_3d (self , n , mode ):
132
+ if mode == 'block' :
133
+ np .block (self .block )
134
+ else : # mode == 'copy'
135
+ [arr .copy () for arr in self .arr_list ]
119
136
120
137
# Retain old benchmark name for backward compat
121
138
time_3d .benchmark_name = "bench_shape_base.Block.time_3d"
0 commit comments