1; function ret=bench_1D(s) ret=zeros(size(s)); for k=1:length(s) a=rand(s(k),1); tic; b=fft(a); ret(k)=toc; printf("time for %dx1 FFT %f s\n",s(k),ret(k)); fflush(stdout); endfor endfunction function calc_and_plot_bench(color) n=fftw("threads"); printf("Number of FFTW threads = %d\n",n); s1D = 2.^[18:25]; #powers of 2 t=bench_1D(s1D); leg=sprintf("-o%c;powers of 2 with %d thread(s);",color,n); loglog(s1D,t,leg) hold on xlabel("size") ylabel("execution time [s]") s1D = 10.^[5:7]; #powers of 10 t=bench_1D(s1D); leg=sprintf("-x%c;powers of 10 with %d thread(s);",color,n); loglog(s1D,t,leg) #FFTW is best at handling sizes of the form 2^a * 3^b * 5^c * 7^d * 11^e * 13^f, where e+f is either 0 or s1D = [5^6*7^2*11 5^5*7^3*11 5^5*7^3*13 5^7*7^2*11]; t=bench_1D(s1D); leg=sprintf("-^%c;prime base with %d thread(s);",color,n); loglog(s1D,t,leg) endfunction hold off fftw("threads",1); calc_and_plot_bench('r'); fftw("threads",6); calc_and_plot_bench('g'); legend("location","northwest") grid on print("fftw_bench.png")