I'm trying to determine the processing time required to perform a FFT of length 500,000 on a Raspberry Pi in C/C++. I have had difficulty finding any information that would be useful for determining this. How would I go about doing this?

  • $\begingroup$ You don't mention which Raspberry Pi and whether you are planning to use GPU intrinsic or pad the FFT to the nearest power of 2. Anyway, on my RPi 4 for N=5e5 it takes about 53 ms for fftw_execute to finish. $\endgroup$
    – jojeck
    Dec 21, 2020 at 11:02
  • $\begingroup$ Are you sure you need that long of an FFT? That will require lots of memory and incur massive latency. $\endgroup$
    – Hilmar
    Dec 21, 2020 at 12:45

1 Answer 1


Since you care about the time it takes, you'll want to use an optimized FFT implementation. That would be FFTw or FFTS, realistically. Historically, FFTw is way dominant in software (I mean, even Matlab uses that), but FFTS works really well on ARM, so might be the better choice for your Pi.

Then you'd just write a minimal C++ program that

  1. creates an fftw_plan / ffts_plan_t
  2. generates random data (std::uniform_real_distribution is your friend in generating real and imaginary parts of numbers)
  3. uses using sc = std::chrono; auto start = sc::steady_clock::now(); as a "start" timer,
  4. fftw_execute/ffts_execute the plan on your random data
  5. auto finished = sc::steady_clock::now();, and
    auto ms = sc::duration_cast<sc::duration<double>>(finished-start).count()*1000; to get the execution time in milliseconds.

You might want to run the actual plan multiple times (maybe even modifying the data in between) and divide the total time by the number of executions, to reduce the measurement error.

A note on the raspberry Pi: If you're using a modern RPi, don't use 32 bit operating systems, but go for an Aarch64 OS. In my experience, not having the SIMD instructions available in 64 bit mode really really hurts numeric throughput performance. (For an FFT, the better loop performance of aarch64 compilers might also help significantly; haven't benchmarked that.)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.