Skip to content

Commit

Permalink
Remove pointless black_box call, add a comment about the `unaligned…
Browse files Browse the repository at this point in the history
…_` benches, and clean up stray semicolon
  • Loading branch information
Thom Chiovoloni committed Jul 6, 2020
1 parent dc4a644 commit a150dcc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/libcore/benches/ascii.rs
Expand Up @@ -60,7 +60,7 @@ macro_rules! benches {
}
)+
}
};
}
}

use test::black_box;
Expand Down
7 changes: 4 additions & 3 deletions src/libcore/benches/ascii/is_ascii.rs
Expand Up @@ -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)+);
Expand All @@ -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)
})
}
Expand Down

0 comments on commit a150dcc

Please sign in to comment.