summaryrefslogtreecommitdiff
path: root/chomp-bench/benches
diff options
context:
space:
mode:
authorGreg Brown <gmb60@cam.ac.uk>2021-04-20 13:22:49 +0100
committerGreg Brown <gmb60@cam.ac.uk>2021-04-20 13:22:49 +0100
commitbb3c8d1455f7a102a0c0abffd757ccace94f77d5 (patch)
tree5c2793598c781c648c4d9cd103414ff47d88adc1 /chomp-bench/benches
parent15f5491028b11bd821bd141183e8b5bf8c1c46af (diff)
Add LALRPOP arithmetic parser.
Diffstat (limited to 'chomp-bench/benches')
-rw-r--r--chomp-bench/benches/arith.rs8
-rw-r--r--chomp-bench/benches/json.rs4
2 files changed, 10 insertions, 2 deletions
diff --git a/chomp-bench/benches/arith.rs b/chomp-bench/benches/arith.rs
index 489a847..f5ca735 100644
--- a/chomp-bench/benches/arith.rs
+++ b/chomp-bench/benches/arith.rs
@@ -28,7 +28,12 @@ fn parse_handwritten(input: &str) -> i64 {
parse_expr(&mut IterWrapper::new(input.chars())).unwrap()
}
+fn parse_lalrpop(parser: &lalr::ExpressionParser, input: &str) -> i64 {
+ parser.parse(input).unwrap()
+}
+
fn bench_parse(c: &mut Criterion) {
+ let lalr_parser = lalr::ExpressionParser::new();
let plot_config = PlotConfiguration::default().summary_scale(AxisScale::Logarithmic);
let mut group = c.benchmark_group("Arith");
group.plot_config(plot_config);
@@ -40,6 +45,9 @@ fn bench_parse(c: &mut Criterion) {
group.bench_with_input(BenchmarkId::new("Handwritten", i), *input, |b, i| {
b.iter(|| parse_handwritten(i))
});
+ group.bench_with_input(BenchmarkId::new("LALRPOP", i), *input, |b, i| {
+ b.iter(|| parse_lalrpop(&lalr_parser, i))
+ });
}
}
diff --git a/chomp-bench/benches/json.rs b/chomp-bench/benches/json.rs
index abe1c28..c6c73ef 100644
--- a/chomp-bench/benches/json.rs
+++ b/chomp-bench/benches/json.rs
@@ -1,8 +1,8 @@
use chewed::{IterWrapper, Parser};
use chomp_bench::json::*;
use criterion::{
- criterion_group, criterion_main, AxisScale, BenchmarkId, Criterion,
- PlotConfiguration, Throughput,
+ criterion_group, criterion_main, AxisScale, BenchmarkId, Criterion, PlotConfiguration,
+ Throughput,
};
const INPUTS: &[&str] = &[