test(bench): profile the full compare workload with gungraun

Adds benches/compare_profile.rs: a gungraun library_benchmark that runs
the entire `compare` workload once at seed 0 under callgrind. It path-
includes the shared examples/_shared/compare_workload.rs module and calls
the new profile_workload() entry point, which invokes all 82 algorithm
runners and folds every result into a checksum so nothing is elided.

gungraun reports the whole-program instruction count and diffs it against
the previous run; the saved callgrind.out
(target/gungraun/heuropt/compare_profile/.../callgrind.full_compare_workload.out)
carries the per-function breakdown for callgrind_annotate. This is the
measurement harness for the function-level optimization campaign.

Round-0 baseline: 357,060,633,544 Ir. The shared module also carries the
example's presentation layer, so the bench gets a commented
`#![allow(dead_code)]` -- but the runner functions are deliberately not
allow-listed, so a runner missing from profile_workload still warns (that
check already caught one omission).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-14 11:24:19 -06:00
co-authored by Claude Opus 4.7
parent 9df9c149d6
commit 1cecd44511
3 changed files with 212 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
//! Whole-program callgrind profile of the `compare` example workload.
//!
//! Runs every algorithm runner once (seed 0) under callgrind via gungraun —
//! the same workload `examples/compare.rs` runs, minus the multi-seed
//! averaging and table printing. gungraun reports the total instruction
//! count and diffs it against the previous run; the saved `callgrind.out`
//! (`target/gungraun/compare_profile/compare_group/full_compare_workload/`)
//! carries the per-function breakdown — `callgrind_annotate` it to rank
//! functions by self-instruction cost.
//!
//! ```bash
//! cargo bench --bench compare_profile
//! ```
// The shared `compare_workload` module also carries the example's
// presentation layer (`run_all`, the `run_*_comparison` printers,
// `print_table`, …), which this profiling benchmark deliberately does not
// use — it drives only the runner functions via `profile_workload`. The
// runner functions themselves are *not* allow-listed, so a runner that
// `profile_workload` forgets to call still warns.
#![allow(dead_code)]
use std::hint::black_box;
use gungraun::prelude::*;
#[path = "../examples/_shared/compare_workload.rs"]
mod workload;
#[library_benchmark]
fn full_compare_workload() -> u64 {
black_box(workload::profile_workload())
}
library_benchmark_group!(
name = compare_group;
benchmarks = full_compare_workload
);
main!(library_benchmark_groups = compare_group);