File tree 2 files changed +5
-4
lines changed
2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ macro_rules! benches {
60
60
}
61
61
) +
62
62
}
63
- } ;
63
+ }
64
64
}
65
65
66
66
use test:: black_box;
Original file line number Diff line number Diff line change @@ -7,7 +7,9 @@ macro_rules! benches {
7
7
benches!( mod short SHORT [ ..] $( $name $arg $body) +) ;
8
8
benches!( mod medium MEDIUM [ ..] $( $name $arg $body) +) ;
9
9
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)
11
13
benches!( mod unaligned_head MEDIUM [ 1 ..] $( $name $arg $body) +) ;
12
14
benches!( mod unaligned_tail MEDIUM [ ..( MEDIUM . len( ) - 1 ) ] $( $name $arg $body) +) ;
13
15
benches!( mod unaligned_both MEDIUM [ 1 ..( MEDIUM . len( ) - 1 ) ] $( $name $arg $body) +) ;
@@ -22,8 +24,7 @@ macro_rules! benches {
22
24
bencher. bytes = $input[ $range] . len( ) as u64 ;
23
25
let mut vec = $input. as_bytes( ) . to_vec( ) ;
24
26
bencher. iter( || {
25
- black_box( & mut vec) ;
26
- let $arg = black_box( & vec[ $range] ) ;
27
+ let $arg: & [ u8 ] = & black_box( & mut vec) [ $range] ;
27
28
black_box( $body)
28
29
} )
29
30
}
You can’t perform that action at this time.
0 commit comments