Skip to content

Commit 0621de8

Browse files
committed
feat(cargo-codspeed): show warning when min time is 0
Signed-off-by: not-matthias <[email protected]>
1 parent 3ae1497 commit 0621de8

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
@@ -209,6 +209,15 @@ fn aggregate_raw_walltime_data(workspace_root: &Path) -> Result<()> {
209209
return Ok(());
210210
}
211211

212+
for bench in &walltime_benchmarks {
213+
if bench.is_invalid() {
214+
eprintln!(
215+
"Warning: Benchmark {} was possibly optimized away",
216+
bench.name()
217+
);
218+
}
219+
}
220+
212221
let results_folder = std::env::var("CODSPEED_PROFILE_FOLDER")
213222
.map(PathBuf::from)
214223
.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)