From b84a3e8b44f8bf025cf0cb3001746a86aa0dd260 Mon Sep 17 00:00:00 2001 From: Moudy Date: Mon, 18 May 2026 16:37:11 +0200 Subject: [PATCH] docs(cycle_bench): document Stats fields and use Display instead of ::format() - Add /// doc comments on Stats {n, best_ms, mean_ms, stdev_ms} clarifying units, semantics, and Bessel's correction. - Replace pub fn format(&self) -> String with impl fmt::Display for Stats, idiomatic and lets println! use {} directly. - Update three call sites accordingly. --- tools/cycle_bench/src/main.rs | 8 ++------ tools/cycle_bench/src/ppe.rs | 2 +- tools/cycle_bench/src/stats.rs | 16 +++++++++++++--- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/tools/cycle_bench/src/main.rs b/tools/cycle_bench/src/main.rs index 6f254868..d002d566 100644 --- a/tools/cycle_bench/src/main.rs +++ b/tools/cycle_bench/src/main.rs @@ -581,7 +581,7 @@ fn print_table(results: &[BenchResult], prove: bool) { let sw = 8_usize; let exec_w = results .iter() - .map(|r| r.exec_stats.format().len()) + .map(|r| r.exec_stats.to_string().len()) .max() .unwrap_or(0) .max("exec_ms (best / mean ± stdev)".len()); @@ -594,11 +594,7 @@ fn print_table(results: &[BenchResult], prove: bool) { for r in results { println!( "{:cw$} {:>sw$} {: String { - format!( +/// `best / mean ± stdev (n=N)` for table display. +impl fmt::Display for Stats { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!( + f, "{:.2} / {:.2} ± {:.2} (n={})", self.best_ms, self.mean_ms, self.stdev_ms, self.n, )