Skip to content

Commit

Permalink
Add two more benchmarks for strictly ASCII and non ASCII cases
Browse files Browse the repository at this point in the history
  • Loading branch information
mcastorina committed Feb 26, 2021
1 parent 8acb566 commit 229fdf8
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions library/core/benches/char/methods.rs
Expand Up @@ -47,11 +47,31 @@ fn bench_to_ascii_lowercase(b: &mut Bencher) {
}

#[bench]
fn bench_char_to_uppercase(b: &mut Bencher) {
fn bench_ascii_mix_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) {
fn bench_ascii_mix_to_lowercase(b: &mut Bencher) {
b.iter(|| (0..=255).cycle().take(10_000).map(|b| char::from(b).to_lowercase()).count())
}

#[bench]
fn bench_ascii_char_to_uppercase(b: &mut Bencher) {
b.iter(|| (0..=127).cycle().take(10_000).map(|b| char::from(b).to_uppercase()).count())
}

#[bench]
fn bench_ascii_char_to_lowercase(b: &mut Bencher) {
b.iter(|| (0..=127).cycle().take(10_000).map(|b| char::from(b).to_lowercase()).count())
}

#[bench]
fn bench_non_ascii_char_to_uppercase(b: &mut Bencher) {
b.iter(|| (128..=255).cycle().take(10_000).map(|b| char::from(b).to_uppercase()).count())
}

#[bench]
fn bench_non_ascii_char_to_lowercase(b: &mut Bencher) {
b.iter(|| (128..=255).cycle().take(10_000).map(|b| char::from(b).to_lowercase()).count())
}

0 comments on commit 229fdf8

Please sign in to comment.