Replace unstable benches with Criterion#143
Conversation
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughMigrates benchmarking from nightly Rust benches to Criterion: adds Criterion as a dev-dependency, introduces a new Criterion benchmark file for Board::get_all_legal_moves, and removes the legacy nightly bench module and feature gate from tests. Changes
Sequence Diagram(s)sequenceDiagram
participant Dev as Developer
participant Cargo as Cargo
participant Criterion as Criterion runner
participant OldBench as Nightly bench harness
rect rgba(46,139,87,0.08)
Note over Cargo,Criterion: New flow (post-change)
Dev->>Cargo: cargo bench
Cargo->>Criterion: run `engine/benches/board_bench.rs` (harness=false)
Criterion->>Board: call get_all_legal_moves (bench loop)
end
rect rgba(220,20,60,0.06)
Note over Cargo,OldBench: Old flow (removed)
Dev->>Cargo: cargo bench
Cargo->>OldBench: run #[bench] harness (nightly/test)
OldBench->>Board: call get_all_legal_moves (removed)
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🔇 Additional comments (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull Request Overview
This PR migrates the benchmark suite from Rust's unstable nightly-only test feature to Criterion, a stable benchmarking framework. This eliminates the need for nightly Rust when running benchmarks.
Key changes:
- Removed the
#![feature(test)]attribute and thebenchesmodule fromtests/board.rs - Created a new Criterion-based benchmark in
benches/board_bench.rsthat testsget_all_legal_movesperformance - Added Criterion as a dev dependency and configured the benchmark harness in
Cargo.toml
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| engine/tests/board.rs | Removed nightly-only benchmark module and feature flag |
| engine/benches/board_bench.rs | Added new Criterion benchmark for get_all_legal_moves |
| engine/Cargo.toml | Added Criterion dev dependency and benchmark configuration |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
engine/benches/board_bench.rs (1)
5-25: LGTM!The benchmark implementation is correct:
- Properly uses
black_boxto prevent compiler optimizations- Tests a representative board state
- Focuses on measuring
get_all_legal_movesperformanceOptionally, you could benchmark multiple board states (early game, mid-game, endgame) to get more comprehensive performance metrics, but this is not necessary for the initial migration.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
engine/Cargo.toml(2 hunks)engine/benches/board_bench.rs(1 hunks)engine/tests/board.rs(0 hunks)
💤 Files with no reviewable changes (1)
- engine/tests/board.rs
🧰 Additional context used
🧬 Code graph analysis (1)
engine/benches/board_bench.rs (1)
engine/src/board.rs (1)
create_from_str(315-332)
🔇 Additional comments (3)
engine/Cargo.toml (1)
41-43: LGTM!The benchmark configuration is correct. Setting
harness = falseis required for Criterion benchmarks, and the name matches the benchmark file.engine/benches/board_bench.rs (2)
1-3: LGTM!All necessary imports are present and correctly structured.
27-28: LGTM!The Criterion setup is correct and follows the standard pattern for defining and running benchmark groups.
Summary
tests/board.rsengine/benches/board_bench.rsTesting
https://chatgpt.com/codex/tasks/task_e_6900bff69068832ba8f77f8a7fa87bd4
Summary by CodeRabbit