benchmark parser

This commit is contained in:
nora 2022-05-01 12:07:06 +02:00
parent 39079710c0
commit aab4d95b21
7 changed files with 47835 additions and 9 deletions

2456
benches/benchfile.dil Normal file

File diff suppressed because it is too large Load diff

26
benches/parser.rs Normal file
View file

@ -0,0 +1,26 @@
use bumpalo::Bump;
use criterion::{black_box, criterion_group, criterion_main, Criterion, Throughput};
fn criterion_benchmark(c: &mut Criterion) {
let source = include_str!("benchfile.dil");
let mut group = c.benchmark_group("parse");
let alloc = Bump::new();
// SAFETY: dropped at the end of function
let mut rt_alloc = unsafe { dilaria::RtAlloc::new() };
group.throughput(Throughput::Bytes(source.len() as u64));
group.bench_function("benchfile.dil", |b| {
b.iter(|| parse(black_box(source), &alloc, &mut rt_alloc));
});
group.finish();
}
fn parse(source: &str, alloc: &Bump, rt_alloc: &mut dilaria::RtAlloc) {
let p = dilaria::_parse(source, alloc, rt_alloc);
black_box(&p);
}
criterion_group!(benches, criterion_benchmark);
criterion_main!(benches);