From 387959675cd53b3c75ad9b6215b07843f8c8f1d8 Mon Sep 17 00:00:00 2001 From: Greg Brown Date: Tue, 11 May 2021 13:53:56 +0100 Subject: Rename autochomp to autonibble. --- autochomp/benches/parse/main.rs | 64 ----------------------------------------- 1 file changed, 64 deletions(-) delete mode 100644 autochomp/benches/parse/main.rs (limited to 'autochomp/benches/parse/main.rs') diff --git a/autochomp/benches/parse/main.rs b/autochomp/benches/parse/main.rs deleted file mode 100644 index 64fd88a..0000000 --- a/autochomp/benches/parse/main.rs +++ /dev/null @@ -1,64 +0,0 @@ -use std::error::Error; - -use chewed::{IterWrapper, Parser}; -use chomp::{ - chomp::ast::NamedExpression, - nibble::{ - self, - convert::{Context, Convert}, - }, -}; -use criterion::{ - criterion_group, criterion_main, AxisScale, BenchmarkId, Criterion, PlotConfiguration, - Throughput, -}; - -const INPUTS: &[&str] = &[ - include_str!("data/12.nb"), - include_str!("data/24.nb"), - include_str!("data/48.nb"), - include_str!("data/97.nb"), - include_str!("data/194.nb"), - include_str!("data/387.nb"), - include_str!("data/774.nb"), - include_str!("data/1548.nb"), - include_str!("data/3096.nb"), - -]; - -fn parse_autochomp(input: &str) -> Result> { - IterWrapper::new(input.chars()) - .parse::() - .map_err(|e| Box::new(e) as Box) - .and_then(|ast| { - ast.convert(&mut Context::default()) - .map_err(|e| Box::new(e) as Box) - }) -} - -fn parse_chomp(input: &str) -> Result> { - syn::parse_str::(input) - .map_err(|e| Box::new(e) as Box) - .and_then(|stmt| { - stmt.convert(&mut Context::default()) - .map_err(|e| Box::new(e) as Box) - }) -} - -fn bench_parse(c: &mut Criterion) { - let plot_config = PlotConfiguration::default().summary_scale(AxisScale::Logarithmic); - let mut group = c.benchmark_group("Parse"); - group.plot_config(plot_config); - for (i, input) in INPUTS.iter().enumerate() { - group.throughput(Throughput::Bytes(input.len() as u64)); - group.bench_with_input(BenchmarkId::new("Chomp", i), *input, |b, i| { - b.iter(|| parse_chomp(i)) - }); - group.bench_with_input(BenchmarkId::new("AutoChomp", i), *input, |b, i| { - b.iter(|| parse_autochomp(i)) - }); - } -} - -criterion_group!(benches, bench_parse); -criterion_main!(benches); -- cgit v1.2.3