Add fuzzer for deeply nested parsing

Signed-off-by: Marcel Müller <neikos@neikos.email>
This commit is contained in:
Marcel Müller 2026-03-11 18:39:57 +01:00
parent dc8281036c
commit 474324726a
2 changed files with 22 additions and 3 deletions

View file

@ -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);