Add array::map benchmarks
This commit is contained in:
parent
5a8dfd933a
commit
cbd1b81bd2
19
library/core/benches/array.rs
Normal file
19
library/core/benches/array.rs
Normal file
@ -0,0 +1,19 @@
|
||||
use test::black_box;
|
||||
use test::Bencher;
|
||||
|
||||
macro_rules! map_array {
|
||||
($func_name:ident, $start_item: expr, $map_item: expr, $arr_size: expr) => {
|
||||
#[bench]
|
||||
fn $func_name(b: &mut Bencher) {
|
||||
let arr = [$start_item; $arr_size];
|
||||
b.iter(|| black_box(arr).map(|_| black_box($map_item)));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
map_array!(map_8byte_8byte_8, 0u64, 1u64, 800);
|
||||
map_array!(map_8byte_8byte_64, 0u64, 1u64, 6400);
|
||||
map_array!(map_8byte_8byte_256, 0u64, 1u64, 25600);
|
||||
|
||||
map_array!(map_8byte_256byte_256, 0u64, [0u64; 4], 25600);
|
||||
map_array!(map_256byte_8byte_256, [0u64; 4], 0u64, 25600);
|
@ -9,6 +9,7 @@
|
||||
extern crate test;
|
||||
|
||||
mod any;
|
||||
mod array;
|
||||
mod ascii;
|
||||
mod char;
|
||||
mod fmt;
|
||||
|
Loading…
x
Reference in New Issue
Block a user