mod util; use criterion::*; use ncase::Words; pub fn build(c: &mut Criterion) { for num_words in [0, 1, 10, 100, 1000] { let s = util::make_string(num_words, " "); let w = Words::from(s.as_str()); let mut group = c.benchmark_group("build"); group.throughput(Throughput::Bytes(s.len() as u64)); group.bench_with_input(BenchmarkId::new("camel", num_words), &w, |b, w| { b.iter(|| w.camel()) }); group.bench_with_input(BenchmarkId::new("pascal", num_words), &w, |b, w| { b.iter(|| w.pascal()) }); group.bench_with_input(BenchmarkId::new("kebab", num_words), &w, |b, w| { b.iter(|| w.kebab()) }); group.bench_with_input( BenchmarkId::new("screaming_kebab", num_words), &w, |b, w| b.iter(|| w.screaming_kebab()), ); group.bench_with_input(BenchmarkId::new("lower", num_words), &w, |b, w| { b.iter(|| w.lower()) }); group.bench_with_input(BenchmarkId::new("upper", num_words), &w, |b, w| { b.iter(|| w.upper()) }); group.bench_with_input(BenchmarkId::new("snake", num_words), &w, |b, w| { b.iter(|| w.snake()) }); group.bench_with_input( BenchmarkId::new("screaming_snake", num_words), &w, |b, w| b.iter(|| w.screaming_snake()), ); group.bench_with_input(BenchmarkId::new("title", num_words), &w, |b, w| { b.iter(|| w.title()) }); group.bench_with_input(BenchmarkId::new("toggle", num_words), &w, |b, w| { b.iter(|| w.toggle()) }); group.bench_with_input(BenchmarkId::new("random", num_words), &w, |b, w| { b.iter(|| w.random()) }); group.finish(); } } criterion_group!(benches, build); criterion_main!(benches);