summaryrefslogtreecommitdiffstats
path: root/vendor/zerovec/benches/zeromap.rs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/zerovec/benches/zeromap.rs')
-rw-r--r--vendor/zerovec/benches/zeromap.rs20
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);
});
});