Skip to main content

render_reason_line

Function render_reason_line 

Source
pub fn render_reason_line(compare: &CompareReceipt, token: &str) -> String
Expand description

Render a single verdict reason token as a human-readable bullet line.

ยงExamples

let compare = CompareReceipt {
    schema: COMPARE_SCHEMA_V1.to_string(),
    tool: ToolInfo { name: "perfgate".into(), version: "0.1.0".into() },
    bench: BenchMeta {
        name: "b".into(), cwd: None,
        command: vec!["echo".into()], repeat: 1, warmup: 0,
        work_units: None, timeout_ms: None,
    },
    baseline_ref: CompareRef { path: None, run_id: None },
    current_ref: CompareRef { path: None, run_id: None },
    budgets: BTreeMap::from([(Metric::WallMs, Budget {
        threshold: 0.20, warn_threshold: 0.10, direction: Direction::Lower,
    })]),
    deltas: BTreeMap::from([(Metric::WallMs, Delta {
        baseline: 100.0, current: 115.0, ratio: 1.15, pct: 0.15,
        regression: 0.15, statistic: MetricStatistic::Median,
        significance: None, status: MetricStatus::Warn,
    })]),
    verdict: Verdict {
        status: VerdictStatus::Warn,
        counts: VerdictCounts { pass: 0, warn: 1, fail: 0 },
        reasons: vec!["wall_ms_warn".into()],
    },
};
let line = perfgate_render::render_reason_line(&compare, "wall_ms_warn");
assert!(line.starts_with("- wall_ms_warn:"));
assert!(line.contains("+15.00%"));