Skip to content

Commit 229fdf8

Browse files
committed
Add two more benchmarks for strictly ASCII and non ASCII cases
1 parent 8acb566 commit 229fdf8

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

library/core/benches/char/methods.rs

+22-2
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,31 @@ fn bench_to_ascii_lowercase(b: &mut Bencher) {
4747
}
4848

4949
#[bench]
50-
fn bench_char_to_uppercase(b: &mut Bencher) {
50+
fn bench_ascii_mix_to_uppercase(b: &mut Bencher) {
5151
b.iter(|| (0..=255).cycle().take(10_000).map(|b| char::from(b).to_uppercase()).count())
5252
}
5353

5454
#[bench]
55-
fn bench_char_to_lowercase(b: &mut Bencher) {
55+
fn bench_ascii_mix_to_lowercase(b: &mut Bencher) {
5656
b.iter(|| (0..=255).cycle().take(10_000).map(|b| char::from(b).to_lowercase()).count())
5757
}
58+
59+
#[bench]
60+
fn bench_ascii_char_to_uppercase(b: &mut Bencher) {
61+
b.iter(|| (0..=127).cycle().take(10_000).map(|b| char::from(b).to_uppercase()).count())
62+
}
63+
64+
#[bench]
65+
fn bench_ascii_char_to_lowercase(b: &mut Bencher) {
66+
b.iter(|| (0..=127).cycle().take(10_000).map(|b| char::from(b).to_lowercase()).count())
67+
}
68+
69+
#[bench]
70+
fn bench_non_ascii_char_to_uppercase(b: &mut Bencher) {
71+
b.iter(|| (128..=255).cycle().take(10_000).map(|b| char::from(b).to_uppercase()).count())
72+
}
73+
74+
#[bench]
75+
fn bench_non_ascii_char_to_lowercase(b: &mut Bencher) {
76+
b.iter(|| (128..=255).cycle().take(10_000).map(|b| char::from(b).to_lowercase()).count())
77+
}

0 commit comments

Comments
 (0)