Add simple bench
Signed-off-by: Marcel Müller <neikos@neikos.email>
This commit is contained in:
parent
8afc2d1bde
commit
b69c659583
5 changed files with 449 additions and 1 deletions
27
benches/parsing.rs
Normal file
27
benches/parsing.rs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
use criterion::BenchmarkId;
|
||||
use criterion::Criterion;
|
||||
use criterion::criterion_group;
|
||||
use criterion::criterion_main;
|
||||
use nomo::input::NomoInput;
|
||||
|
||||
fn parsing_benchmark(c: &mut Criterion) {
|
||||
let mut parsing = c.benchmark_group("Parsing");
|
||||
|
||||
for size in [1, 10, 200, 1000] {
|
||||
let mut input = String::new();
|
||||
|
||||
for _ in 0..size {
|
||||
input.push_str("{{ if foo }}{{= variable }}{{ 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);
|
||||
criterion_main!(benches);
|
||||
Loading…
Add table
Add a link
Reference in a new issue