Commit cb5caad
committed
chore(ndarray): migrate benches off nightly #![feature(test)] to criterion 0.5 + Tier A clippy fixes
User directive: stable Rust 1.94.1 only — no nightly features anywhere.
The bench tests used #![feature(test)] + extern crate test + #[bench]
(unstable libtest_bench framework), blocking CI on stable. Migrated all
13 benches to criterion 0.5 (already established workspace pattern via
crates/p64 + crates/phyllotactic-manifold).
Files migrated (10 source files; append.rs/construct.rs/numeric.rs were
already criterion-based; Cargo.toml + ndarray-rand/Cargo.toml had the
[[bench]] + criterion dev-dep prep already in working tree):
benches/bench1.rs (1106 LOC, ~80 #[bench] fns + mat_mul! macro)
benches/iter.rs (436 LOC, ~30 #[bench] fns)
benches/par_rayon.rs (182 LOC, rayon-feature-gated)
benches/zip.rs (133 LOC)
benches/to_shape.rs (95 LOC)
benches/higher-order.rs (93 LOC)
benches/chunks.rs (87 LOC)
benches/gemv_gemm.rs (75 LOC)
benches/reserve.rs (31 LOC)
ndarray-rand/benches/bench.rs (31 LOC)
Mechanical conversion pattern:
BEFORE: #[bench] fn name(b: &mut Bencher) { b.iter(|| ...); }
AFTER: fn name(c: &mut Criterion) { c.bench_function("name", |b| b.iter(|| ...)); }
criterion_group!(benches, name1, name2, ...);
criterion_main!(benches);
Bench function names preserved exactly so `cargo bench --bench foo name`
keeps working. Wrapped inputs with criterion's black_box where the
original used test::black_box.
Special handling:
- bench1.rs's mat_mul! macro now generates pub fn $name(c: &mut Criterion)
inside each module + a pub fn group(c) that calls them all. Top-level
criterion_group!(matmul_benches, mat_mul_f32::group, ...) registers
all 30 generated benches.
- bench1.rs split into 11 criterion_groups (iter/sum/add/scalar/
add_strided/iadd_scalar/iter_misc/dot/dimensionality/matmul/std) for
readability; criterion_main! aggregates them all.
- iter.rs splits #[cfg(feature = "std")] benches into a separate
criterion_group with conditional criterion_main! inclusion.
Tier A clippy fixes (per user request to ship clean):
- examples/life.rs:1 + tests/assign.rs:1 + tests/array.rs:1 +
benches/bench1.rs:1 + benches/iter.rs:1 — added
#[allow(clippy::reversed_empty_ranges)] for the s![1..-1, ..]
Python-style negative-indexing macro pattern (false positive — clippy
can't see through s! macro).
- tests/oper.rs:300 — replaced unsafe Vec::with_capacity + set_len
uninit pattern with proper MaybeUninit<A>::uninit + write per slot
+ ManuallyDrop transmute. SAFETY comments document each unsafe block.
Verification (per user "use clippy not check"):
cargo clippy --benches --tests --examples --features rayon --no-deps
→ 0 errors in benches/tests/examples (down from 18+).
5 pre-existing lib code errors remain (NOT introduced here, NOT in scope
for this commit):
- src/hpc/quantized.rs:431 + src/hpc/blackboard.rs:484-485 +
src/hpc/jitson/parser.rs:487 — clippy::approx_constant
(literal PI values; should use std::f{32,64}::consts::PI)
- src/hpc/renderer.rs:428 — clippy::absurd_extreme_comparisons
These are lib-level tech debt visible to `cargo clippy --lib` and
require separate fix commits.1 parent 130aa8d commit cb5caad
20 files changed
Lines changed: 1387 additions & 955 deletions
File tree
- benches
- examples
- ndarray-rand
- benches
- tests
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
74 | 124 | | |
75 | 125 | | |
76 | 126 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | | - | |
| 1 | + | |
6 | 2 | | |
7 | 3 | | |
8 | | - | |
9 | | - | |
10 | | - | |
| 4 | + | |
11 | 5 | | |
12 | 6 | | |
13 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
14 | 10 | | |
15 | 11 | | |
16 | | - | |
17 | | - | |
18 | | - | |
| 12 | + | |
19 | 13 | | |
20 | 14 | | |
21 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
22 | 18 | | |
23 | 19 | | |
24 | | - | |
25 | | - | |
26 | | - | |
| 20 | + | |
27 | 21 | | |
28 | 22 | | |
29 | 23 | | |
30 | | - | |
31 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
32 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
0 commit comments