Files
zen/core/expression/benches/unary.rs
stefan-gorules 602d214b96 feat: expression static analysis (#449)
* feat: expression static analysis

* fix: cargo fmt

* fix: python workflow

* fix: python workflow

* fix: python workflow

* fix: ignore miri test bound by clock

* fix: memory leaks
2026-06-22 15:48:05 +02:00

33 lines
867 B
Rust

use bumpalo::Bump;
use criterion::{criterion_group, criterion_main, Bencher, Criterion};
use zen_expression::lexer::Lexer;
use zen_expression::parser::Parser;
fn bench_source(b: &mut Bencher, src: &'static str) {
let mut lexer = Lexer::new();
let token_bump = Bump::new();
let mut bump = Bump::new();
let tokens = lexer.tokenize(&token_bump, src).unwrap();
b.iter(|| {
let unary_parser = Parser::try_new(&tokens, &bump).unwrap().unary();
criterion::black_box(unary_parser.parse());
bump.reset();
})
}
fn bench_functions(c: &mut Criterion) {
c.bench_function("unary/simple", |b| {
bench_source(b, "'hello world'");
});
c.bench_function("unary/large", |b| {
bench_source(b, "'a', 'b', 'c', 'd', 'e', 'f'")
});
}
criterion_group!(benches, bench_functions);
criterion_main!(benches);