Add benchmarking code for json parser
This commit is contained in:
parent
b86cbfd8ff
commit
1e91bf4efd
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user