Add fuzzer for deeply nested parsing
Signed-off-by: Marcel Müller <neikos@neikos.email>
This commit is contained in:
parent
dc8281036c
commit
474324726a
2 changed files with 22 additions and 3 deletions
|
|
@ -23,5 +23,26 @@ fn parsing_benchmark(c: &mut Criterion) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
criterion_group!(benches, parsing_benchmark);
|
fn parsing_nested(c: &mut Criterion) {
|
||||||
|
let mut parsing = c.benchmark_group("Parsing");
|
||||||
|
|
||||||
|
for size in [1, 2, 8, 12] {
|
||||||
|
let mut input = String::new();
|
||||||
|
|
||||||
|
for _ in 0..size {
|
||||||
|
input = format!(
|
||||||
|
"{{{{ for foo in bar }}}} {input} {{{{ if foo }}}} Hi! {input} {{{{ end }}}} Yooo {{{{ end }}}}"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
let input = NomoInput::from(input);
|
||||||
|
|
||||||
|
parsing.throughput(criterion::Throughput::Bytes(input.len() as u64));
|
||||||
|
parsing.bench_with_input(BenchmarkId::from_parameter(size), &input, |b, input| {
|
||||||
|
b.iter(|| nomo::parser::parse(input.clone()).unwrap());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
criterion_group!(benches, parsing_benchmark, parsing_nested);
|
||||||
criterion_main!(benches);
|
criterion_main!(benches);
|
||||||
|
|
|
||||||
2
fuzz/Cargo.lock
generated
2
fuzz/Cargo.lock
generated
|
|
@ -116,7 +116,6 @@ version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"annotate-snippets",
|
"annotate-snippets",
|
||||||
"displaydoc",
|
"displaydoc",
|
||||||
"serde",
|
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"winnow",
|
"winnow",
|
||||||
|
|
@ -161,7 +160,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
|
checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde_core",
|
"serde_core",
|
||||||
"serde_derive",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue