SigPack - the C++ signal processing library
fftw_loop.cpp

Output

Armadillo FFT Time = 46.8176
FFTW Loop[1]. Time = 0.052592
FFTW Loop[2]. Time = 0.003976
FFTW Loop[3]. Time = 0.003865
FFTW Loop[4]. Time = 0.003716

Source

#include "sigpack.h"
using namespace arma;
using namespace sp;
int main()
{
int N = 45191; // Large prime number
FFTW ss(N, FFTW_ESTIMATE);
vec x(N);
cx_vec Sxx(N);
vec P(N);
clock_t tic;
x.randn();
tic = clock();
Sxx = fft(x);
cout << " Armadillo FFT Time = " << (clock() - tic) / double(CLOCKS_PER_SEC)
<< endl;
for (int n = 1; n < 5; n++)
{
x.randn();
tic = clock();
Sxx = ss.fft(x);
cout << "FFTW Loop[" << n
<< "]. Time = " << (clock() - tic) / double(CLOCKS_PER_SEC) << endl;
}
return 0;
}