-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbench_fftw.nim
32 lines (23 loc) · 943 Bytes
/
bench_fftw.nim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import complex, math, benchy, fftw3
proc benchFFT(name: string, size: int) =
GC_fullCollect()
var
input = newSeq[Complex64](size)
timeit name & " - " & $size:
var output = newSeq[Complex64](size)
let bufIn = cast[ptr UncheckedArray[Complex64]](addr(input[0]))
let bufOut = cast[ptr UncheckedArray[Complex64]](addr(output[0]))
let plan = fftw_plan_dft_1d(cint size, bufIn, bufOut, FFTW_FORWARD, FFTW_ESTIMATE)
fftw_execute(plan)
for size in [64, 128, 256, 512, 1024, 2048, 4096, 16384, 65536]:
benchFFT("pow2", size)
for size in [5, 17, 149, 151, 251, 1009, 2017, 2879, 32767, 65521, 65537, 746483, 746497]:
benchFFT "prime", size
for size in [211^2, 401^2]:
benchFFT "prime-power", size
for size in [24576, 20736]:
benchFFT "mult-of-power-of-2", size
for size in [30270]:
benchFFT "small-comp-large-prime", size
for size in [18, 360, 44100, 48000, 46656, 100000]:
benchFFT "small-comp", size