rust-parser-combinator/benches/json-benchmark.rs

15 lines
448 B
Rust
Raw Permalink Normal View History

2023-03-10 00:45:04 -08:00
use criterion::{black_box, criterion_group, criterion_main, Criterion};
2023-03-10 01:16:06 -08:00
use parser_combinator::testutil::json_object;
use parser_combinator::Parser;
2023-03-10 00:45:04 -08:00
pub fn criterion_benchmark(c: &mut Criterion) {
2023-03-10 01:16:06 -08:00
let test_json = include_str!("../tests/joplin-cfg.json");
c.bench_function("parse_json", |b| {
b.iter(|| json_object().parse(black_box(test_json)))
});
2023-03-10 00:45:04 -08:00
}
criterion_group!(benches, criterion_benchmark);
criterion_main!(benches);