Commits

Bryan O'Sullivan committed 2e0ca11

Add criterion-based benchmarks

  • Participants
  • Parent commits b371d36

Comments (0)

Files changed (3)

-^(?:cabal-dev|dist|tests/dist)$
+^(?:cabal-dev|dist|benchmarks/dist|tests/dist)$
 ^demo/demo$
 \.(?:aux|eventlog|h[ip]|log|[oa]|orig|prof|ps|rej|swp)$
 ~$

benchmarks/Benchmarks.hs

+{-# LANGUAGE OverloadedStrings #-}
+
+import Criterion.Main
+import Data.Double.Conversion
+import qualified Data.Text as T
+
+showText :: Double -> T.Text
+showText d = T.pack (show d)
+
+main = defaultMain [
+         bench "show" $ whnf showText pi
+       , bench "toShortest" $ whnf toShortest pi
+       , bench "toExponential" $ whnf (toExponential 3) pi
+       , bench "toPrecision" $ whnf (toExponential 8) pi
+       , bench "toFixed" $ whnf (toFixed 8) pi
+       ]

benchmarks/double-conversion-benchmarks.cabal

+name:           double-conversion-benchmarks
+version:        0
+cabal-version:  >= 1.8
+build-type:     Simple
+
+executable bm
+  main-is: Benchmarks.hs
+
+  build-depends:
+    base,
+    criterion >= 0.5.0.10,
+    double-conversion,
+    text >= 0.11.0.8