-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add BlobSchema V2 with ZeroTrie (#4207)
- Loading branch information
Showing
15 changed files
with
469 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// This file is part of ICU4X. For terms of use, please see the file | ||
// called LICENSE at the top level of the ICU4X source tree | ||
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). | ||
|
||
extern crate alloc; | ||
|
||
use criterion::{black_box, criterion_group, criterion_main, Criterion}; | ||
use icu_provider::datagen::IterableDataProvider; | ||
use icu_provider::hello_world::*; | ||
use icu_provider::prelude::*; | ||
use icu_provider_blob::BlobDataProvider; | ||
|
||
const BLOB_V1: &[u8] = include_bytes!("../tests/data/v1.postcard"); | ||
const BLOB_V2: &[u8] = include_bytes!("../tests/data/v2.postcard"); | ||
|
||
fn blob_version_bench(c: &mut Criterion) { | ||
c.bench_function("provider/construct/v1", |b| { | ||
b.iter(|| BlobDataProvider::try_new_from_static_blob(black_box(BLOB_V1)).unwrap()); | ||
}); | ||
c.bench_function("provider/construct/v2", |b| { | ||
b.iter(|| BlobDataProvider::try_new_from_static_blob(black_box(BLOB_V1)).unwrap()); | ||
}); | ||
|
||
let hello_world_provider = HelloWorldProvider; | ||
let locales = hello_world_provider.supported_locales().unwrap(); | ||
|
||
c.bench_function("provider/read/v1", |b| { | ||
let provider = BlobDataProvider::try_new_from_static_blob(black_box(BLOB_V1)).unwrap(); | ||
b.iter(|| { | ||
for locale in black_box(&locales).iter() { | ||
black_box(&provider) | ||
.load_buffer( | ||
HelloWorldV1Marker::KEY, | ||
DataRequest { | ||
locale, | ||
metadata: Default::default(), | ||
}, | ||
) | ||
.unwrap(); | ||
} | ||
}); | ||
}); | ||
c.bench_function("provider/read/v2", |b| { | ||
let provider = BlobDataProvider::try_new_from_static_blob(black_box(BLOB_V2)).unwrap(); | ||
b.iter(|| { | ||
for locale in black_box(&locales).iter() { | ||
black_box(&provider) | ||
.load_buffer( | ||
HelloWorldV1Marker::KEY, | ||
DataRequest { | ||
locale, | ||
metadata: Default::default(), | ||
}, | ||
) | ||
.unwrap(); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
criterion_group!(benches, blob_version_bench,); | ||
criterion_main!(benches); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.