summaryrefslogtreecommitdiffstats
path: root/vendor/litemap/benches/litemap.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--vendor/litemap/benches/litemap.rs22
1 files changed, 4 insertions, 18 deletions
diff --git a/vendor/litemap/benches/litemap.rs b/vendor/litemap/benches/litemap.rs
index 68906037d..b32b8ba87 100644
--- a/vendor/litemap/benches/litemap.rs
+++ b/vendor/litemap/benches/litemap.rs
@@ -2,8 +2,6 @@
// called LICENSE at the top level of the ICU4X source tree
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
-use std::fs;
-
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use litemap::LiteMap;
@@ -40,7 +38,6 @@ const POSTCARD: [u8; 176] = [
];
/// Run this function to print new data to the console.
-/// Requires the optional `serde` Cargo feature.
#[allow(dead_code)]
fn generate() {
let map = build_litemap(false);
@@ -48,11 +45,8 @@ fn generate() {
println!("{buf:?}");
}
-#[cfg(feature = "generate")]
-fn generate_test_data() {
- let map = build_litemap(true);
- let bytes = postcard::to_stdvec(&map).unwrap();
- fs::write("large_litemap.postcard", &bytes).unwrap();
+fn large_litemap_postcard_bytes() -> Vec<u8> {
+ postcard::to_stdvec(&build_litemap(true)).unwrap()
}
fn overview_bench(c: &mut Criterion) {
@@ -92,7 +86,7 @@ fn bench_deserialize(c: &mut Criterion) {
}
fn bench_deserialize_large(c: &mut Criterion) {
- let buf = read_large_litemap_postcard_bytes();
+ let buf = large_litemap_postcard_bytes();
c.bench_function("litemap/deseralize/large", |b| {
b.iter(|| {
let map: LiteMap<String, String> = postcard::from_bytes(black_box(&buf)).unwrap();
@@ -112,7 +106,7 @@ fn bench_lookup(c: &mut Criterion) {
}
fn bench_lookup_large(c: &mut Criterion) {
- let buf = read_large_litemap_postcard_bytes();
+ let buf = large_litemap_postcard_bytes();
let map: LiteMap<String, String> = postcard::from_bytes(&buf).unwrap();
c.bench_function("litemap/lookup/large", |b| {
b.iter(|| {
@@ -122,13 +116,5 @@ fn bench_lookup_large(c: &mut Criterion) {
});
}
-fn read_large_litemap_postcard_bytes() -> Vec<u8> {
- let path = concat!(
- env!("CARGO_MANIFEST_DIR"),
- "/benches/testdata/large_litemap.postcard"
- );
- fs::read(path).unwrap()
-}
-
criterion_group!(benches, overview_bench);
criterion_main!(benches);