Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to avoid the performance loss of rfft function after using fft function? #305

Closed
liushang0322 opened this issue Jul 9, 2024 · 1 comment

Comments

@liushang0322
Copy link

using FFTW
using Random
a = rand(100000000)
@time rfft(a);
0.307048 seconds (228 allocations: 762.957 MiB, 7.69% gc time)

But when I use fft once first and then use the above code

using FFTW
using Random
a = rand(100000000)
fft(a)
@time rfft(a);
2.986037 seconds (228 allocations: 762.957 MiB, 1.63% gc time)

Performance is about ten times worse,How to avoid the performance loss of rfft function after using fft function?

@stevengj
Copy link
Member

stevengj commented Jul 9, 2024

I can't replicate your timings on my machine. I suspect that you're just being fooled by the unreliability of @time (in particular, you want to discount the time from the first time you call a function, since not only is some compilation involved, but FFTW also creates a "plan" object that can potentially be re-used. Better to use @btime from the BenchmarkTools.jl package to get reliable timing measurements.

However, if you care about performance, you should be using plan_rfft anyway to create a "plan" (saved algorithm and data tables) for the FFT and then re-use it.

@stevengj stevengj closed this as completed Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants