summaryrefslogtreecommitdiffstats
path: root/vendor/icu_locid_transform/benches
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
commitef24de24a82fe681581cc130f342363c47c0969a (patch)
tree0d494f7e1a38b95c92426f58fe6eaa877303a86c /vendor/icu_locid_transform/benches
parentReleasing progress-linux version 1.74.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-ef24de24a82fe681581cc130f342363c47c0969a.tar.xz
rustc-ef24de24a82fe681581cc130f342363c47c0969a.zip
Merging upstream version 1.75.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/icu_locid_transform/benches')
-rw-r--r--vendor/icu_locid_transform/benches/fixtures/locales.json41
-rw-r--r--vendor/icu_locid_transform/benches/fixtures/uncanonicalized-locales.json88
-rw-r--r--vendor/icu_locid_transform/benches/helpers/mod.rs15
-rw-r--r--vendor/icu_locid_transform/benches/locale_canonicalizer.rs99
4 files changed, 243 insertions, 0 deletions
diff --git a/vendor/icu_locid_transform/benches/fixtures/locales.json b/vendor/icu_locid_transform/benches/fixtures/locales.json
new file mode 100644
index 000000000..0e8ba8b79
--- /dev/null
+++ b/vendor/icu_locid_transform/benches/fixtures/locales.json
@@ -0,0 +1,41 @@
+[
+ "en-US",
+ "en-GB",
+ "es-AR",
+ "it",
+ "zh-Hans-CN",
+ "de-AT",
+ "pl",
+ "fr-FR",
+ "de-AT",
+ "sr-Cyrl-SR",
+ "nb-NO",
+ "fr-FR",
+ "mk",
+ "uk",
+ "und-PL",
+ "und-Latn-AM",
+ "ug-Cyrl",
+ "sr-ME",
+ "mn-Mong",
+ "lif-Limb",
+ "gan",
+ "zh-Hant",
+ "yue-Hans",
+ "unr",
+ "unr-Deva",
+ "und-Thai-CN",
+ "ug-Cyrl",
+ "en-Latn-DE",
+ "pl-FR",
+ "de-CH",
+ "tuq",
+ "sr-ME",
+ "ng",
+ "klx",
+ "kk-Arab",
+ "en-Cyrl",
+ "und-Cyrl-UK",
+ "und-Arab",
+ "und-Arab-FO"
+]
diff --git a/vendor/icu_locid_transform/benches/fixtures/uncanonicalized-locales.json b/vendor/icu_locid_transform/benches/fixtures/uncanonicalized-locales.json
new file mode 100644
index 000000000..18eadbce6
--- /dev/null
+++ b/vendor/icu_locid_transform/benches/fixtures/uncanonicalized-locales.json
@@ -0,0 +1,88 @@
+[
+ "cka",
+ "cze",
+ "gfx",
+ "sgn-BR",
+ "sgn-DD",
+ "tam",
+ "und-aaland",
+ "nob-bokmal",
+ "no-nynorsk",
+ "und-Qaai",
+ "en-554",
+ "en-084",
+ "art-lojban",
+ "zh-guoyu",
+ "zh-hakka",
+ "zh-xiang",
+ "aar-x-private",
+ "heb-x-private",
+ "ces",
+ "hy-arevela",
+ "hy-arevmda",
+ "cel-gaulish",
+ "ja-latn-hepburn-heploc",
+ "ja-Latn-fonipa-hepburn-heploc",
+ "und-Armn-SU",
+ "sh",
+ "sh-Cyrl",
+ "cnr",
+ "cnr-BA",
+ "ru-SU",
+ "ru-810",
+ "en-SU",
+ "en-810",
+ "und-SU",
+ "und-810",
+ "und-Latn-SU",
+ "und-Latn-810",
+ "hy-SU",
+ "hy-810",
+ "und-Armn-SU",
+ "und-Armn-810",
+ "sr-CS",
+ "sr-Latn-CS",
+ "sr-Cyrl-CS",
+ "az-NT",
+ "sl-t-sl-rozaj-biske-1994",
+ "DE-T-M0-DIN-K0-QWERTZ",
+ "en-t-m0-true",
+ "en-t-iw",
+ "und-u-rg-no23",
+ "und-u-rg-cn11",
+ "und-u-rg-cz10a",
+ "und-u-rg-fra",
+ "und-u-rg-frg",
+ "und-u-rg-lud",
+ "und-NO-u-rg-no23",
+ "und-CN-u-rg-cn11",
+ "und-CZ-u-rg-cz10a",
+ "und-FR-u-rg-fra",
+ "und-FR-u-rg-frg",
+ "und-u-rg-lud",
+ "und-u-sd-no23",
+ "und-u-sd-cn11",
+ "und-u-sd-cz10a",
+ "und-u-sd-fra",
+ "hy-arevela",
+ "hy-Armn-arevela",
+ "hy-AM-arevela",
+ "hy-arevela-fonipa",
+ "hy-fonipa-arevela",
+ "hy-arevmda",
+ "hy-Armn-arevmda",
+ "hy-AM-arevmda",
+ "hy-arevmda-fonipa",
+ "hy-fonipa-arevmda",
+ "ja-Latn-hepburn-heploc",
+ "ja-Latn-JP-hepburn-heploc",
+ "sv-aaland",
+ "el-polytoni",
+ "ja-Latn-alalc97-hepburn-heploc",
+ "ja-Latn-hepburn-alalc97-heploc",
+ "ja-Latn-hepburn-heploc-alalc97",
+ "ja-Latn-heploc-hepburn",
+ "ja-Latn-heploc",
+ "ja-Latn-aaland-heploc",
+ "ja-Latn-heploc-polytoni"
+]
diff --git a/vendor/icu_locid_transform/benches/helpers/mod.rs b/vendor/icu_locid_transform/benches/helpers/mod.rs
new file mode 100644
index 000000000..d250c510c
--- /dev/null
+++ b/vendor/icu_locid_transform/benches/helpers/mod.rs
@@ -0,0 +1,15 @@
+// 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 ).
+
+use std::fs::File;
+use std::io::{BufReader, Error};
+
+pub fn read_fixture<T>(path: &str) -> Result<T, Error>
+where
+ T: serde::de::DeserializeOwned,
+{
+ let file = File::open(path)?;
+ let reader = BufReader::new(file);
+ Ok(serde_json::from_reader(reader)?)
+}
diff --git a/vendor/icu_locid_transform/benches/locale_canonicalizer.rs b/vendor/icu_locid_transform/benches/locale_canonicalizer.rs
new file mode 100644
index 000000000..1ea8df6b3
--- /dev/null
+++ b/vendor/icu_locid_transform/benches/locale_canonicalizer.rs
@@ -0,0 +1,99 @@
+// 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 ).
+
+mod helpers;
+
+use criterion::{black_box, criterion_group, criterion_main, Criterion};
+use icu_locid::Locale;
+use icu_locid_transform::LocaleCanonicalizer;
+use icu_locid_transform::LocaleExpander;
+
+fn canonicalize_bench(c: &mut Criterion) {
+ let lc = LocaleCanonicalizer::new();
+
+ let mut group = c.benchmark_group("uncanonicalized");
+
+ let path = "./benches/fixtures/uncanonicalized-locales.json";
+ let data: Vec<String> = helpers::read_fixture(path).expect("Failed to read a fixture");
+ let locales: Vec<Locale> = data.iter().map(|s| s.parse().unwrap()).collect();
+
+ group.bench_function("clone", |b| {
+ b.iter(|| {
+ for locale in &locales {
+ let _ = black_box(locale).clone();
+ }
+ })
+ });
+
+ group.bench_function("canonicalize", |b| {
+ b.iter(|| {
+ for locale in &locales {
+ let mut locale = black_box(locale).clone();
+ lc.canonicalize(&mut locale);
+ }
+ })
+ });
+
+ group.finish();
+}
+
+fn canonicalize_noop_bench(c: &mut Criterion) {
+ let lc = LocaleCanonicalizer::new();
+
+ let mut group = c.benchmark_group("canonicalized");
+
+ // None of these locales require canonicalization, so this measures the cost of calling
+ // the canonicalizer on locales that will not be modified.
+ let path = "./benches/fixtures/locales.json";
+ let data: Vec<String> = helpers::read_fixture(path).expect("Failed to read a fixture");
+ let locales: Vec<Locale> = data.iter().map(|s| s.parse().unwrap()).collect();
+
+ group.bench_function("clone", |b| {
+ b.iter(|| {
+ for locale in &locales {
+ let _ = black_box(locale).clone();
+ }
+ })
+ });
+
+ group.bench_function("canonicalize", |b| {
+ b.iter(|| {
+ for locale in &locales {
+ let mut locale = black_box(locale).clone();
+ lc.canonicalize(&mut locale);
+ }
+ })
+ });
+
+ group.finish();
+}
+
+fn maximize_bench(c: &mut Criterion) {
+ let lc = LocaleExpander::new();
+
+ let mut group = c.benchmark_group("likelysubtags");
+
+ let path = "./benches/fixtures/locales.json";
+ let data: Vec<String> = helpers::read_fixture(path).expect("Failed to read a fixture");
+ let locales: Vec<Locale> = data.iter().map(|s| s.parse().unwrap()).collect();
+
+ group.bench_function("maximize", |b| {
+ b.iter(|| {
+ for locale in &locales {
+ let mut locale = locale.clone();
+ lc.maximize(black_box(&mut locale));
+ }
+ })
+ });
+
+ group.finish();
+}
+
+criterion_group!(
+ benches,
+ canonicalize_bench,
+ canonicalize_noop_bench,
+ maximize_bench
+);
+criterion_main!(benches);