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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue