aboutsummaryrefslogtreecommitdiff
path: root/benches
diff options
context:
space:
mode:
Diffstat (limited to 'benches')
-rw-r--r--benches/parse.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/benches/parse.rs b/benches/parse.rs
new file mode 100644
index 0000000..f7b7412
--- /dev/null
+++ b/benches/parse.rs
@@ -0,0 +1,21 @@
+use criterion::*;
+use std::fs::read_to_string;
+use std::hint::black_box;
+
+use wmap_parser::*;
+
+fn bench(c: &mut Criterion) {
+ let mut group = c.benchmark_group("Parsing");
+ let example_source = read_to_string("doc/example.wmap").unwrap();
+ let huge_source = read_to_string("doc/huge.wmap").unwrap();
+
+ group.sample_size(500);
+ group.bench_function("parse example", |b| {
+ b.iter(|| parse(black_box(&example_source)))
+ });
+ group.bench_function("parse huge", |b| b.iter(|| parse(black_box(&huge_source))));
+ group.finish();
+}
+
+criterion_group!(benches, bench);
+criterion_main!(benches);