From 1e91bf4efd9a69e49ed0b07eb5c89bc2a51226eb Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Fri, 10 Mar 2023 01:16:06 -0800 Subject: [PATCH] Add benchmarking code for json parser --- benches/json-benchmark.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/benches/json-benchmark.rs b/benches/json-benchmark.rs index b4c6a9a..3dd3353 100644 --- a/benches/json-benchmark.rs +++ b/benches/json-benchmark.rs @@ -1,8 +1,13 @@ use criterion::{black_box, criterion_group, criterion_main, Criterion}; -use tests::json_parser::json_object; +use parser_combinator::testutil::json_object; +use parser_combinator::Parser; pub fn criterion_benchmark(c: &mut Criterion) { - c.bench_function("fib 20", |b| b.iter(|| fibonacci(black_box(20)))); + let test_json = include_str!("../tests/joplin-cfg.json"); + + c.bench_function("parse_json", |b| { + b.iter(|| json_object().parse(black_box(test_json))) + }); } criterion_group!(benches, criterion_benchmark);