diff options
| author | kadmin <julianknodt@gmail.com> | 2023-02-11 03:04:36 +0000 |
|---|---|---|
| committer | kadmin <julianknodt@gmail.com> | 2023-02-11 04:23:53 +0000 |
| commit | cbd1b81bd2a308b0f8a1734daf3eb30b56c7537c (patch) | |
| tree | a21804d8b73d7d620e8f1a3dc270fd4009eca09c | |
| parent | 5a8dfd933a70cc47e44502a20fd67dfaec6555d5 (diff) | |
| download | rust-cbd1b81bd2a308b0f8a1734daf3eb30b56c7537c.tar.gz rust-cbd1b81bd2a308b0f8a1734daf3eb30b56c7537c.zip | |
Add array::map benchmarks
| -rw-r--r-- | library/core/benches/array.rs | 19 | ||||
| -rw-r--r-- | library/core/benches/lib.rs | 1 |
2 files changed, 20 insertions, 0 deletions
diff --git a/library/core/benches/array.rs b/library/core/benches/array.rs new file mode 100644 index 00000000000..845c6076294 --- /dev/null +++ b/library/core/benches/array.rs @@ -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); diff --git a/library/core/benches/lib.rs b/library/core/benches/lib.rs index f1244d93285..e4100120d82 100644 --- a/library/core/benches/lib.rs +++ b/library/core/benches/lib.rs @@ -9,6 +9,7 @@ extern crate test; mod any; +mod array; mod ascii; mod char; mod fmt; |
