Add to_lowercase and to_uppercase char benchmarks

This commit is contained in:
Miccah Castorina 2021-01-24 20:29:44 -06:00
parent e48c68479e
commit 8acb566507

View file

@ -45,3 +45,13 @@ fn bench_to_ascii_uppercase(b: &mut Bencher) {
fn bench_to_ascii_lowercase(b: &mut Bencher) {
b.iter(|| CHARS.iter().cycle().take(10_000).map(|c| c.to_ascii_lowercase()).min())
}
#[bench]
fn bench_char_to_uppercase(b: &mut Bencher) {
b.iter(|| (0..=255).cycle().take(10_000).map(|b| char::from(b).to_uppercase()).count())
}
#[bench]
fn bench_char_to_lowercase(b: &mut Bencher) {
b.iter(|| (0..=255).cycle().take(10_000).map(|b| char::from(b).to_lowercase()).count())
}