Add read-update-write benchmarks

Add benchmarks for parsing, updating, and serializing in Rust and C.
Update the fork instructions in AGENTS.md.
This commit is contained in:
2026-05-04 23:13:53 -07:00
parent ea68537f0b
commit a0c2747583
3 changed files with 59 additions and 2 deletions
+29 -1
View File
@@ -205,11 +205,39 @@ fn bench_iterate(c: &mut Criterion) {
group.finish();
}
/// Parse, update a field, and serialize back to a buffer.
fn bench_read_update_write(c: &mut Criterion) {
let cases = [
("tiny", load("tiny")),
("small", load("small")),
("medium", load("medium")),
];
let mut group = c.benchmark_group("read_update_write");
for (label, maybe_data) in &cases {
let Some(data) = maybe_data else { continue };
group.throughput(Throughput::Bytes(data.len() as u64));
group.bench_with_input(BenchmarkId::new("Campaign", label), data, |b, data| {
b.iter(|| {
let campaign = Campaign::new(data).unwrap();
let mut buf = vec![0u8; data.len() * 2];
let res = CampaignBuilder::builder(&mut buf)
.name("updated")
.with(&campaign)
.finish();
black_box(res)
})
});
}
group.finish();
}
criterion_group!(
benches,
bench_shallow_parse,
bench_deep_parse,
bench_field_access,
bench_iterate
bench_iterate,
bench_read_update_write
);
criterion_main!(benches);