mirror of
https://github.com/Noratrieb/dilaria.git
synced 2026-01-15 18:05:03 +01:00
benchmark parser
This commit is contained in:
parent
39079710c0
commit
aab4d95b21
7 changed files with 47835 additions and 9 deletions
26
benches/parser.rs
Normal file
26
benches/parser.rs
Normal 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);
|
||||
Loading…
Add table
Add a link
Reference in a new issue