File tree 2 files changed +21
-0
lines changed
2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change 1
1
use core:: iter:: * ;
2
+ use core:: mem;
3
+ use core:: num:: Wrapping ;
2
4
use test:: { black_box, Bencher } ;
3
5
4
6
#[ bench]
@@ -398,3 +400,21 @@ fn bench_trusted_random_access_adapters(b: &mut Bencher) {
398
400
acc
399
401
} )
400
402
}
403
+
404
+ /// Exercises the iter::Copied specialization for slice::Iter
405
+ #[ bench]
406
+ fn bench_copied_array_chunks ( b : & mut Bencher ) {
407
+ let v = vec ! [ 1u8 ; 1024 ] ;
408
+
409
+ b. iter ( || {
410
+ black_box ( & v)
411
+ . iter ( )
412
+ . copied ( )
413
+ . array_chunks :: < { mem:: size_of :: < u64 > ( ) } > ( )
414
+ . map ( |ary| {
415
+ let d = u64:: from_ne_bytes ( ary) ;
416
+ Wrapping ( d. rotate_left ( 7 ) . wrapping_add ( 1 ) )
417
+ } )
418
+ . sum :: < Wrapping < u64 > > ( )
419
+ } )
420
+ }
Original file line number Diff line number Diff line change 4
4
#![ feature( int_log) ]
5
5
#![ feature( test) ]
6
6
#![ feature( trusted_random_access) ]
7
+ #![ feature( iter_array_chunks) ]
7
8
8
9
extern crate test;
9
10
You can’t perform that action at this time.
0 commit comments