73e1238e20
- Replace flat parser with state machine (Normal/Decorator/InFunction) - Change parse_script to accept reference and add proper error handling - Add Function::find_decorator helper method - Refactor build_script to accept &Function and support @if/@export decorators - Add condition code generation for @if decorator - Add export/preexport code for environment variable capture - Handle trivial scripts by creating Function directly - Add constants: PIPELINE_SKIP_ERRORCODE and TRIVIAL_SCRIPT_NAME - Temporarily disable order-based sorting assertion (see TODO) - Add empty finalize.rs module skeleton - Update integration tests to expect errors appropriately
62 lines
1.9 KiB
Rust
62 lines
1.9 KiB
Rust
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
|
use std::fs;
|
|
use std::path::Path;
|
|
|
|
fn parse_large_script(c: &mut Criterion) {
|
|
let script_path = Path::new("/tmp/bench_large.sh");
|
|
|
|
let script_content = fs::read_to_string(script_path)
|
|
.expect("Failed to read benchmark script. Run `python3 benches/generate.py` first.");
|
|
|
|
let byte_size = script_content.len();
|
|
let line_count = script_content.lines().count();
|
|
|
|
println!("Benchmark file: {} lines, {} bytes", line_count, byte_size);
|
|
|
|
c.bench_function("parse_script_large", |b| {
|
|
b.iter(|| {
|
|
let result =
|
|
workshop_baker::bake::parser::parse_script(black_box(&script_content.clone()));
|
|
black_box(result)
|
|
});
|
|
});
|
|
}
|
|
|
|
fn parse_medium_script(c: &mut Criterion) {
|
|
let script_path = Path::new("/tmp/bench_medium.sh");
|
|
|
|
let script_content = fs::read_to_string(script_path)
|
|
.expect("Failed to read benchmark script. Run `python3 benches/generate.py` first.");
|
|
|
|
c.bench_function("parse_script_medium", |b| {
|
|
b.iter(|| {
|
|
let result =
|
|
workshop_baker::bake::parser::parse_script(black_box(&script_content.clone()));
|
|
black_box(result)
|
|
});
|
|
});
|
|
}
|
|
|
|
fn parse_small_script(c: &mut Criterion) {
|
|
let script_path = Path::new("/tmp/bench_small.sh");
|
|
|
|
let script_content = fs::read_to_string(script_path)
|
|
.expect("Failed to read benchmark script. Run `python3 benches/generate.py` first.");
|
|
|
|
c.bench_function("parse_script_small", |b| {
|
|
b.iter(|| {
|
|
let result =
|
|
workshop_baker::bake::parser::parse_script(black_box(&script_content.clone()));
|
|
black_box(result)
|
|
});
|
|
});
|
|
}
|
|
|
|
criterion_group!(
|
|
benches,
|
|
parse_small_script,
|
|
parse_medium_script,
|
|
parse_large_script
|
|
);
|
|
criterion_main!(benches);
|