Skip to content

Commit 8acb566

Browse files
committed
Add to_lowercase and to_uppercase char benchmarks
1 parent e48c684 commit 8acb566

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

library/core/benches/char/methods.rs

+10
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,13 @@ fn bench_to_ascii_uppercase(b: &mut Bencher) {
4545
fn bench_to_ascii_lowercase(b: &mut Bencher) {
4646
b.iter(|| CHARS.iter().cycle().take(10_000).map(|c| c.to_ascii_lowercase()).min())
4747
}
48+
49+
#[bench]
50+
fn bench_char_to_uppercase(b: &mut Bencher) {
51+
b.iter(|| (0..=255).cycle().take(10_000).map(|b| char::from(b).to_uppercase()).count())
52+
}
53+
54+
#[bench]
55+
fn bench_char_to_lowercase(b: &mut Bencher) {
56+
b.iter(|| (0..=255).cycle().take(10_000).map(|b| char::from(b).to_lowercase()).count())
57+
}

0 commit comments

Comments
 (0)