File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -202,3 +202,35 @@ fn vector_sum_3_zip_unchecked(bench: &mut Bencher)
202
202
}
203
203
} ) ;
204
204
}
205
+
206
+ // index iterator size
207
+ const ISZ : usize = 16 ;
208
+
209
+ #[ bench]
210
+ fn indexed_iter_3d_ix3 ( bench : & mut Bencher ) {
211
+ let mut a = Array :: < f64 , _ > :: zeros ( ( ISZ , ISZ , ISZ ) ) ;
212
+ for ( ( i, j, k) , elt) in a. indexed_iter_mut ( ) {
213
+ * elt = ( i + 100 * j + 10000 * k) as _ ;
214
+ }
215
+
216
+ bench. iter ( || {
217
+ for ( i, & elt) in a. indexed_iter ( ) {
218
+ assert ! ( a[ i] == elt) ;
219
+ }
220
+ } )
221
+ }
222
+
223
+ #[ bench]
224
+ fn indexed_iter_3d_dyn ( bench : & mut Bencher ) {
225
+ let mut a = Array :: < f64 , _ > :: zeros ( ( ISZ , ISZ , ISZ ) ) ;
226
+ for ( ( i, j, k) , elt) in a. indexed_iter_mut ( ) {
227
+ * elt = ( i + 100 * j + 10000 * k) as _ ;
228
+ }
229
+ let a = a. into_shape ( & [ ISZ ; 3 ] [ ..] ) . unwrap ( ) ;
230
+
231
+ bench. iter ( || {
232
+ for ( i, & elt) in a. indexed_iter ( ) {
233
+ assert ! ( a[ i] == elt) ;
234
+ }
235
+ } )
236
+ }
You can’t perform that action at this time.
0 commit comments