Skip to content

Commit

Permalink
Add benchmark for FFT
Browse files Browse the repository at this point in the history
  • Loading branch information
Shimuuar committed Aug 6, 2012
1 parent 27d6a2b commit c9b2033
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions benchmark/bench.hs
@@ -1,11 +1,13 @@

import Control.Monad.ST (runST)
import Data.Complex
import qualified Data.Vector.Unboxed as U

import System.Random.MWC
import qualified Data.Vector.Unboxed as U
import Criterion.Main

import Statistics.Sample
import Statistics.Transform


-- Test sample
sample :: U.Vector Double
Expand All @@ -15,6 +17,11 @@ sample = runST $ flip uniformVector 10000 =<< create
sampleW :: U.Vector (Double,Double)
sampleW = U.zip sample (U.reverse sample)

-- Comlex vector for FFT tests
sampleC :: U.Vector (Complex Double)
sampleC = U.zipWith (:+) sample (U.reverse sample)


-- Simple benchmark for functions from Statistics.Sample
main :: IO ()
main =
Expand All @@ -40,4 +47,22 @@ main =
, bench "C.M. 4" $ nf (\x -> centralMoment 4 x) sample
, bench "C.M. 5" $ nf (\x -> centralMoment 5 x) sample
]
, bgroup "FFT"
[ bgroup "fft"
[ bench (show n) $ whnf fft (U.take n sampleC) | n <- fftSizes ]
, bgroup "ifft"
[ bench (show n) $ whnf ifft (U.take n sampleC) | n <- fftSizes ]
, bgroup "dct"
[ bench (show n) $ whnf dct (U.take n sample) | n <- fftSizes ]
, bgroup "dct_"
[ bench (show n) $ whnf dct_ (U.take n sampleC) | n <- fftSizes ]
, bgroup "idct"
[ bench (show n) $ whnf idct (U.take n sample) | n <- fftSizes ]
, bgroup "idct_"
[ bench (show n) $ whnf idct_ (U.take n sampleC) | n <- fftSizes ]
]
]


fftSizes :: [Int]
fftSizes = [32,128,512,2048]

0 comments on commit c9b2033

Please sign in to comment.