Skip to content

Commit

Permalink
Add benchmark suite
Browse files Browse the repository at this point in the history
  • Loading branch information
expipiplus1 committed Nov 18, 2015
1 parent 9890a9f commit dfd3fc1
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
36 changes: 36 additions & 0 deletions bench/Bench.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
module Main where

import Criterion.Main
import Data.CReal.Internal

main :: IO ()
main = defaultMain [ bgroup "pi" [ bench "0" $ whnf (pi `atPrecision`) 0
, bench "4" $ whnf (pi `atPrecision`) 4
, bench "16" $ whnf (pi `atPrecision`) 16
, bench "64" $ whnf (pi `atPrecision`) 64
, bench "256" $ whnf (pi `atPrecision`) 256
, bench "1024" $ whnf (pi `atPrecision`) 1024
]
, bgroup "sin 1" [ bench "0" $ whnf (sin 1 `atPrecision`) 0
, bench "4" $ whnf (sin 1 `atPrecision`) 4
, bench "16" $ whnf (sin 1 `atPrecision`) 16
, bench "64" $ whnf (sin 1 `atPrecision`) 64
, bench "256" $ whnf (sin 1 `atPrecision`) 256
, bench "1024" $ whnf (sin 1 `atPrecision`) 1024
]
, bgroup "sin (π/4)" [ bench "0" $ whnf (sin (pi/4) `atPrecision`) 0
, bench "4" $ whnf (sin (pi/4) `atPrecision`) 4
, bench "16" $ whnf (sin (pi/4) `atPrecision`) 16
, bench "64" $ whnf (sin (pi/4) `atPrecision`) 64
, bench "256" $ whnf (sin (pi/4) `atPrecision`) 256
, bench "1024" $ whnf (sin (pi/4) `atPrecision`) 1024
]
, bgroup "asin (π/4)" [ bench "0" $ whnf (asin (pi/4) `atPrecision`) 0
, bench "4" $ whnf (asin (pi/4) `atPrecision`) 4
, bench "16" $ whnf (asin (pi/4) `atPrecision`) 16
, bench "64" $ whnf (asin (pi/4) `atPrecision`) 64
, bench "256" $ whnf (asin (pi/4) `atPrecision`) 256
, bench "1024" $ whnf (asin (pi/4) `atPrecision`) 1024
]
]

16 changes: 16 additions & 0 deletions exact-real.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,22 @@ library
ghc-options:
-Wall

benchmark bench
default-language:
Haskell2010
type:
exitcode-stdio-1.0
ghc-options:
-Wall -threaded -O2
hs-source-dirs:
bench
main-is:
Bench.hs
build-depends:
base >= 4 && < 5,
criterion >= 1.1 && < 1.2,
exact-real

test-suite test
default-language:
Haskell2010
Expand Down

0 comments on commit dfd3fc1

Please sign in to comment.