Add reverse benchmarks for u128, [u8;3], and Simd<[f64;4]>

None of these are affected by e8fad325fe.
This commit is contained in:
Scott McMurray 2017-05-05 20:50:48 -07:00
parent 1f891d11f5
commit da91361d2a
2 changed files with 12 additions and 6 deletions

View File

@ -10,7 +10,9 @@
#![deny(warnings)]
#![feature(i128_type)]
#![feature(rand)]
#![feature(repr_simd)]
#![feature(sort_unstable)]
#![feature(test)]

View File

@ -292,14 +292,14 @@ sort!(sort_unstable, sort_unstable_large_strings, gen_strings, 10000);
sort_expensive!(sort_unstable_by, sort_unstable_large_random_expensive, gen_random, 10000);
macro_rules! reverse {
($name:ident, $ty:ident) => {
($name:ident, $ty:ty, $f:expr) => {
#[bench]
fn $name(b: &mut Bencher) {
// odd length and offset by 1 to be as unaligned as possible
let n = 0xFFFFF;
let mut v: Vec<_> =
(0..1+(n / mem::size_of::<$ty>() as u64))
.map(|x| x as $ty)
.map($f)
.collect();
b.iter(|| black_box(&mut v[1..]).reverse());
b.bytes = n;
@ -307,7 +307,11 @@ macro_rules! reverse {
}
}
reverse!(reverse_u8, u8);
reverse!(reverse_u16, u16);
reverse!(reverse_u32, u32);
reverse!(reverse_u64, u64);
reverse!(reverse_u8, u8, |x| x as u8);
reverse!(reverse_u16, u16, |x| x as u16);
reverse!(reverse_u8x3, [u8;3], |x| [x as u8, (x>>8) as u8, (x>>16) as u8]);
reverse!(reverse_u32, u32, |x| x as u32);
reverse!(reverse_u64, u64, |x| x as u64);
reverse!(reverse_u128, u128, |x| x as u128);
#[repr(simd)] struct F64x4(f64, f64, f64, f64);
reverse!(reverse_simd_f64x4, F64x4, |x| { let x = x as f64; F64x4(x,x,x,x) });