diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:41 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:41 +0000 |
commit | 4f9fe856a25ab29345b90e7725509e9ee38a37be (patch) | |
tree | e4ffd8a9374cae7b21f7cbfb352927e0e074aff6 /vendor/zerovec/benches/zeromap.rs | |
parent | Adding upstream version 1.68.2+dfsg1. (diff) | |
download | rustc-5cd5bd4daf55da04d2c8e7c06c3067a027cfbfc2.tar.xz rustc-5cd5bd4daf55da04d2c8e7c06c3067a027cfbfc2.zip |
Adding upstream version 1.69.0+dfsg1.upstream/1.69.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | vendor/zerovec/benches/zeromap.rs | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/vendor/zerovec/benches/zeromap.rs b/vendor/zerovec/benches/zeromap.rs index 40225ba7a..069331979 100644 --- a/vendor/zerovec/benches/zeromap.rs +++ b/vendor/zerovec/benches/zeromap.rs @@ -56,7 +56,8 @@ const POSTCARD_HASHMAP: [u8; 176] = [ 114, 97, 98, 105, 99, ]; -/// Run this function to print new data to the console. Requires the optional `serde` feature. +/// Run this function to print new data to the console. +/// Requires the optional `serde` Cargo feature. #[allow(dead_code)] fn generate() { let map = build_zeromap(false); @@ -64,7 +65,8 @@ fn generate() { println!("{:?}", buf); } -/// Run this function to print new data to the console. Requires the optional `serde` feature. +/// Run this function to print new data to the console. +/// Requires the optional `serde` Cargo feature. #[allow(dead_code)] fn generate_hashmap() { let map = build_hashmap(false); @@ -180,13 +182,13 @@ fn bench_hashmap(c: &mut Criterion) { fn build_hashmap(large: bool) -> HashMap<String, String> { let mut map: HashMap<String, String> = HashMap::new(); - for (key, value) in DATA.iter() { + for &(key, value) in DATA.iter() { if large { for n in 0..8192 { - map.insert(format!("{}{}", key, n), value.to_string()); + map.insert(format!("{}{}", key, n), value.to_owned()); } } else { - map.insert(key.to_string(), value.to_string()); + map.insert(key.to_owned(), value.to_owned()); } } map @@ -197,7 +199,7 @@ fn bench_deserialize_hashmap(c: &mut Criterion) { b.iter(|| { let map: HashMap<String, String> = postcard::from_bytes(black_box(&POSTCARD_HASHMAP)).unwrap(); - assert_eq!(map.get("iu"), Some(&"Inuktitut".to_string())); + assert_eq!(map.get("iu"), Some(&"Inuktitut".to_owned())); }) }); } @@ -207,7 +209,7 @@ fn bench_deserialize_large_hashmap(c: &mut Criterion) { c.bench_function("zeromap/deserialize/large/hashmap", |b| { b.iter(|| { let map: HashMap<String, String> = postcard::from_bytes(black_box(&buf)).unwrap(); - assert_eq!(map.get("iu3333"), Some(&"Inuktitut".to_string())); + assert_eq!(map.get("iu3333"), Some(&"Inuktitut".to_owned())); }) }); } @@ -216,7 +218,7 @@ fn bench_lookup_hashmap(c: &mut Criterion) { let map: HashMap<String, String> = postcard::from_bytes(black_box(&POSTCARD_HASHMAP)).unwrap(); c.bench_function("zeromap/lookup/small/hashmap", |b| { b.iter(|| { - assert_eq!(map.get(black_box("iu")), Some(&"Inuktitut".to_string())); + assert_eq!(map.get(black_box("iu")), Some(&"Inuktitut".to_owned())); assert_eq!(map.get(black_box("zz")), None); }); }); @@ -227,7 +229,7 @@ fn bench_lookup_large_hashmap(c: &mut Criterion) { let map: HashMap<String, String> = postcard::from_bytes(&buf).unwrap(); c.bench_function("zeromap/lookup/large/hashmap", |b| { b.iter(|| { - assert_eq!(map.get(black_box("iu3333")), Some(&"Inuktitut".to_string())); + assert_eq!(map.get(black_box("iu3333")), Some(&"Inuktitut".to_owned())); assert_eq!(map.get(black_box("zz")), None); }); }); |