Add benchmarking code for json parser

This commit is contained in:
Greg Shuflin 2023-03-10 01:16:06 -08:00
parent b86cbfd8ff
commit 1e91bf4efd

View File

@ -1,8 +1,13 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion}; 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) { 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); criterion_group!(benches, criterion_benchmark);