From f391522483255a34fc792b2b242fe0e424a335b1 Mon Sep 17 00:00:00 2001 From: BD103 <59022059+BD103@users.noreply.github.com> Date: Sun, 29 Dec 2024 14:33:06 -0500 Subject: [PATCH] Test benchmarks in CI (#16987) # Objective - This reverts #16833, and completely goes against #16803. - Turns out running `cargo test --benches` runs each benchmark once, without timing it, just to ensure nothing panics. This is actually desired because we can use it to verify benchmarks are working correctly without all the time constraints of actual benchmarks. ## Solution - Add the `--benches` flag to the CI test command. ## Testing - `cargo run -p ci -- test` --- benches/benches/bevy_tasks/iter.rs | 4 ++-- tools/ci/src/commands/test.rs | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/benches/benches/bevy_tasks/iter.rs b/benches/benches/bevy_tasks/iter.rs index 4f8f75c8ed..47c2f6de14 100644 --- a/benches/benches/bevy_tasks/iter.rs +++ b/benches/benches/bevy_tasks/iter.rs @@ -61,7 +61,7 @@ fn bench_for_each(c: &mut Criterion) { b.iter(|| { v.iter_mut().for_each(|x| { busy_work(10000); - *x *= *x; + *x = x.wrapping_mul(*x); }); }); }); @@ -77,7 +77,7 @@ fn bench_for_each(c: &mut Criterion) { b.iter(|| { ParChunksMut(v.chunks_mut(100)).for_each(&pool, |x| { busy_work(10000); - *x *= *x; + *x = x.wrapping_mul(*x); }); }); }, diff --git a/tools/ci/src/commands/test.rs b/tools/ci/src/commands/test.rs index 82a64e02a0..bdb4b663d1 100644 --- a/tools/ci/src/commands/test.rs +++ b/tools/ci/src/commands/test.rs @@ -17,7 +17,9 @@ impl Prepare for TestCommand { vec![PreparedCommand::new::( cmd!( sh, - "cargo test --workspace --lib --bins --tests {no_fail_fast}" + // `--benches` runs each benchmark once in order to verify that they behave + // correctly and do not panic. + "cargo test --workspace --lib --bins --tests --benches {no_fail_fast}" ), "Please fix failing tests in output above.", )]