U13: remove the ignored ec-dsp throughput timing test; it asserts nothing and only prints
Browse files at this commit4d056340054f872a6ca94d0e49dd4784f677fb63Parent: 55f05c31 changed file +0 -91
- crates/ec-dsp/src/lib.rs +0 -91
crates/ec-dsp/src/lib.rsmodified+0 -91
| @@ -222,97 +222,6 @@ mod tests { | ||
| 222 | 222 | (num / den.max(f64::MIN_POSITIVE)).sqrt() |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | - /// Throughput, printed rather than asserted: the numbers are machine | |
| 226 | - /// specific, but a regression of the *order of magnitude* is what the | |
| 227 | - /// family cares about (an incumbent shipped an O(n^2) transform and lost | |
| 228 | - /// 40x). Run with: | |
| 229 | - /// | |
| 230 | - /// `cargo test -p ec-dsp --release -- --ignored --nocapture throughput` | |
| 231 | - #[test] | |
| 232 | - #[ignore = "timing; run in release with --ignored --nocapture"] | |
| 233 | - fn throughput() { | |
| 234 | - use crate::{Complex, Fft, Mdct, RealFft, Window}; | |
| 235 | - use std::time::Instant; | |
| 236 | - | |
| 237 | - let n = 2048; | |
| 238 | - let signal: Vec<f32> = noise(n, 0xdeadbeef); | |
| 239 | - let mut guard = 0.0f32; | |
| 240 | - | |
| 241 | - let mut fft = Fft::<f32>::new(n); | |
| 242 | - let mut data: Vec<Complex<f32>> = signal.iter().map(|v| Complex::new(*v, 0.0)).collect(); | |
| 243 | - let iters = 50_000; | |
| 244 | - // Alternating directions keeps the in-place data bounded, so the | |
| 245 | - // numbers are not measured on infinities; the inverse costs one extra | |
| 246 | - // scaling pass, which makes this average slightly pessimistic. | |
| 247 | - let t0 = Instant::now(); | |
| 248 | - for i in 0..iters { | |
| 249 | - if i % 2 == 0 { | |
| 250 | - fft.forward(&mut data); | |
| 251 | - } else { | |
| 252 | - fft.inverse(&mut data); | |
| 253 | - } | |
| 254 | - } | |
| 255 | - report("complex FFT f32 2048 fwd/inv", t0.elapsed(), iters, n); | |
| 256 | - guard += data[0].re; | |
| 257 | - | |
| 258 | - let mut re: Vec<f32> = signal.clone(); | |
| 259 | - let mut im: Vec<f32> = vec![0.0; n]; | |
| 260 | - let t0 = Instant::now(); | |
| 261 | - for i in 0..iters { | |
| 262 | - if i % 2 == 0 { | |
| 263 | - fft.forward_split(&mut re, &mut im); | |
| 264 | - } else { | |
| 265 | - fft.inverse_split(&mut re, &mut im); | |
| 266 | - } | |
| 267 | - } | |
| 268 | - report("split FFT f32 2048 fwd/inv", t0.elapsed(), iters, n); | |
| 269 | - guard += re[0]; | |
| 270 | - | |
| 271 | - let mut rfft = RealFft::<f32>::new(n); | |
| 272 | - let mut spectrum = vec![Complex::new(0.0f32, 0.0); n / 2 + 1]; | |
| 273 | - let t0 = Instant::now(); | |
| 274 | - for _ in 0..iters { | |
| 275 | - rfft.forward(&signal, &mut spectrum); | |
| 276 | - } | |
| 277 | - report("real FFT f32 2048 fwd", t0.elapsed(), iters, n); | |
| 278 | - guard += spectrum[0].re; | |
| 279 | - | |
| 280 | - let mut mdct = Mdct::<f32>::new(n); | |
| 281 | - let window = Window::<f32>::kbd(n, 4.0); | |
| 282 | - let mut coeffs = vec![0.0f32; n / 2]; | |
| 283 | - let t0 = Instant::now(); | |
| 284 | - for _ in 0..iters { | |
| 285 | - mdct.forward_windowed(&signal, window.as_slice(), &mut coeffs); | |
| 286 | - } | |
| 287 | - report("MDCT f32 2048 fwd (windowed)", t0.elapsed(), iters, n); | |
| 288 | - guard += coeffs[0]; | |
| 289 | - | |
| 290 | - let mut frame = vec![0.0f32; n]; | |
| 291 | - let t0 = Instant::now(); | |
| 292 | - for _ in 0..iters { | |
| 293 | - mdct.inverse_windowed(&coeffs, window.as_slice(), &mut frame); | |
| 294 | - } | |
| 295 | - report("IMDCT f32 2048 inv (windowed)", t0.elapsed(), iters, n); | |
| 296 | - guard += frame[0]; | |
| 297 | - | |
| 298 | - // 48 kHz stereo AAC: 2 channels * 46.875 long blocks per second. | |
| 299 | - let per_block = t0.elapsed().as_secs_f64() / iters as f64; | |
| 300 | - println!("guard {guard:e}"); | |
| 301 | - println!( | |
| 302 | - "one 2048 IMDCT = {:.2} us; a 5.1 48 kHz stream needs 6*46.9 = 281 per second", | |
| 303 | - per_block * 1e6 | |
| 304 | - ); | |
| 305 | - } | |
| 306 | - | |
| 307 | - fn report(label: &str, elapsed: std::time::Duration, iters: u32, n: usize) { | |
| 308 | - let per = elapsed.as_secs_f64() / iters as f64; | |
| 309 | - println!( | |
| 310 | - "{label:<32} {:>8.0} ns/transform {:>7.1} Mpoint/s", | |
| 311 | - per * 1e9, | |
| 312 | - n as f64 / per / 1e6 | |
| 313 | - ); | |
| 314 | - } | |
| 315 | - | |
| 316 | 225 | #[test] |
| 317 | 226 | fn scale_matches_scalar_across_the_lane_boundary() { |
| 318 | 227 | for n in [1usize, 3, 8, 9, 17, 64] { |