#![allow(missing_docs, unused_results, clippy::unwrap_used)]
use criterion::{Criterion, criterion_group, criterion_main};
use noyalib::{Spanned, from_str};
use std::hint::black_box;
#[derive(serde::Deserialize)]
#[allow(dead_code)]
struct ErrorHeavy {
items: Vec<Spanned<u8>>,
}
fn bench_span_resolution_on_error(c: &mut Criterion) {
let mut items = Vec::new();
for i in 0..1000 {
items.push(format!(" - {}", i % 256));
}
items.push(" - 300".to_string());
let yaml = format!("items:\n{}", items.join("\n"));
let _ = c.bench_function("span_resolution_error_path", |b| {
b.iter(|| {
let res: Result<ErrorHeavy, _> = from_str(black_box(&yaml));
let _ = black_box(res);
});
});
}
criterion_group!(benches, bench_span_resolution_on_error);
criterion_main!(benches);