File tree Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ macro_rules! benches {
6060 }
6161 ) +
6262 }
63- } ;
63+ }
6464}
6565
6666use test:: black_box;
Original file line number Diff line number Diff line change @@ -7,7 +7,9 @@ macro_rules! benches {
77 benches!( mod short SHORT [ ..] $( $name $arg $body) +) ;
88 benches!( mod medium MEDIUM [ ..] $( $name $arg $body) +) ;
99 benches!( mod long LONG [ ..] $( $name $arg $body) +) ;
10-
10+ // Ensure we benchmark cases where the functions are called with strings
11+ // that are not perfectly aligned or have a length which is not a
12+ // multiple of size_of::<usize>() (or both)
1113 benches!( mod unaligned_head MEDIUM [ 1 ..] $( $name $arg $body) +) ;
1214 benches!( mod unaligned_tail MEDIUM [ ..( MEDIUM . len( ) - 1 ) ] $( $name $arg $body) +) ;
1315 benches!( mod unaligned_both MEDIUM [ 1 ..( MEDIUM . len( ) - 1 ) ] $( $name $arg $body) +) ;
@@ -22,8 +24,7 @@ macro_rules! benches {
2224 bencher. bytes = $input[ $range] . len( ) as u64 ;
2325 let mut vec = $input. as_bytes( ) . to_vec( ) ;
2426 bencher. iter( || {
25- black_box( & mut vec) ;
26- let $arg = black_box( & vec[ $range] ) ;
27+ let $arg: & [ u8 ] = & black_box( & mut vec) [ $range] ;
2728 black_box( $body)
2829 } )
2930 }
You can’t perform that action at this time.
0 commit comments