mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-31 06:22:00 +00:00
Remove pointless black_box
call, add a comment about the unaligned_
benches, and clean up stray semicolon
This commit is contained in:
parent
dc4a644980
commit
a150dcc872
@ -60,7 +60,7 @@ macro_rules! benches {
|
||||
}
|
||||
)+
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
use test::black_box;
|
||||
|
@ -7,7 +7,9 @@ macro_rules! benches {
|
||||
benches!(mod short SHORT[..] $($name $arg $body)+);
|
||||
benches!(mod medium MEDIUM[..] $($name $arg $body)+);
|
||||
benches!(mod long LONG[..] $($name $arg $body)+);
|
||||
|
||||
// Ensure we benchmark cases where the functions are called with strings
|
||||
// that are not perfectly aligned or have a length which is not a
|
||||
// multiple of size_of::<usize>() (or both)
|
||||
benches!(mod unaligned_head MEDIUM[1..] $($name $arg $body)+);
|
||||
benches!(mod unaligned_tail MEDIUM[..(MEDIUM.len() - 1)] $($name $arg $body)+);
|
||||
benches!(mod unaligned_both MEDIUM[1..(MEDIUM.len() - 1)] $($name $arg $body)+);
|
||||
@ -22,8 +24,7 @@ macro_rules! benches {
|
||||
bencher.bytes = $input[$range].len() as u64;
|
||||
let mut vec = $input.as_bytes().to_vec();
|
||||
bencher.iter(|| {
|
||||
black_box(&mut vec);
|
||||
let $arg = black_box(&vec[$range]);
|
||||
let $arg: &[u8] = &black_box(&mut vec)[$range];
|
||||
black_box($body)
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user