Skip to content

Commit 5ab0ad8

Browse files
committed
feat(cargo-codspeed): show warning when min time is 0
1 parent 8110c9e commit 5ab0ad8

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

crates/cargo-codspeed/src/run.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,15 @@ fn aggregate_raw_walltime_data(workspace_root: &Path) -> Result<()> {
202202
return Ok(());
203203
}
204204

205+
for bench in &walltime_benchmarks {
206+
if bench.is_invalid() {
207+
eprintln!(
208+
"Warning: Benchmark {} was possibly optimized away",
209+
bench.name()
210+
);
211+
}
212+
}
213+
205214
let results_folder = std::env::var("CODSPEED_PROFILE_FOLDER")
206215
.map(PathBuf::from)
207216
.unwrap_or_else(|_| workspace_root.join("target/codspeed/profiles"))

crates/cargo-codspeed/src/walltime_results.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@ pub struct WalltimeBenchmark {
4141
stats: BenchmarkStats,
4242
}
4343

44+
impl WalltimeBenchmark {
45+
pub(crate) fn is_invalid(&self) -> bool {
46+
self.stats.min_ns < f64::EPSILON
47+
}
48+
49+
pub(crate) fn name(&self) -> &str {
50+
&self.metadata.name
51+
}
52+
}
53+
4454
impl From<RawWallTimeData> for WalltimeBenchmark {
4555
fn from(value: RawWallTimeData) -> Self {
4656
let times_ns: Vec<f64> = value.times_ns.iter().map(|&t| t as f64).collect();

0 commit comments

Comments
 (0)