diff --git a/Cargo.toml b/Cargo.toml index d9c39de..24b3549 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,6 +18,7 @@ multiversion = "0.7" utilities = { path = "utilities" } fftw = "0.8.0" criterion = "0.5.1" +realfft = "3.3.0" [[bench]] name = "bench" diff --git a/benches/bench.rs b/benches/bench.rs index 17eaa8a..2c5c60f 100644 --- a/benches/bench.rs +++ b/benches/bench.rs @@ -1,9 +1,13 @@ use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion, Throughput}; -use phastft::{fft::r2c_fft_f64, fft_64, planner::Direction}; +use realfft::num_complex::Complex; +use realfft::RealFftPlanner; use utilities::gen_random_signal; +use phastft::{fft::r2c_fft_f64, fft_64, planner::Direction}; + fn criterion_benchmark(c: &mut Criterion) { - let sizes = vec![1 << 10, 1 << 12, 1 << 14, 1 << 16, 1 << 18, 1 << 20]; + // let sizes = vec![1 << 10, 1 << 12, 1 << 14, 1 << 16, 1 << 18, 1 << 20]; + let sizes = vec![1 << 18, 1 << 20]; let mut group = c.benchmark_group("r2c_versus_c2c"); for &size in &sizes { @@ -39,6 +43,20 @@ fn criterion_benchmark(c: &mut Criterion) { ); }); }); + + group.bench_with_input(BenchmarkId::new("real_fft", size), &size, |b, &size| { + let mut s_re = vec![0.0; size]; + let mut s_im = vec![0.0; size]; + gen_random_signal(&mut s_re, &mut s_im); + let mut output = vec![Complex::default(); s_re.len() / 2 + 1]; + + b.iter(|| { + let mut planner = RealFftPlanner::::new(); + let fft = planner.plan_fft_forward(s_re.len()); + fft.process(&mut s_re, &mut output) + .expect("fft.process() failed!"); + }); + }); } group.finish(); }