mod util; use criterion::*; use ncase::Words; use util::make_string; pub fn split(c: &mut Criterion) { for num_words in [0, 1, 10, 100, 1000] { let mut group = c.benchmark_group("split"); group.throughput(Throughput::Bytes(make_string(num_words, "").len() as u64)); group.bench_with_input( BenchmarkId::new("whitespace", num_words), &make_string(num_words, " "), |b, s| b.iter(|| Words::from(s.as_str())), ); group.bench_with_input( BenchmarkId::new("hyphen", num_words), &make_string(num_words, "-"), |b, s| b.iter(|| Words::from(s.as_str())), ); group.bench_with_input( BenchmarkId::new("underscore", num_words), &make_string(num_words, "_"), |b, s| b.iter(|| Words::from(s.as_str())), ); group.bench_with_input( BenchmarkId::new("case", num_words), &make_string(num_words, ""), |b, s| b.iter(|| Words::from(s.as_str())), ); group.finish(); } } criterion_group!(benches, split); criterion_main!(benches);