Permalink
Browse files

Add criterion-based benchmarks

  • Loading branch information...
1 parent 50f2c5b commit 72a388125551b6a1aaeddc11de46626704c7003e @bos committed Jun 27, 2011
Showing with 30 additions and 1 deletion.
  1. +1 −1 .hgignore
  2. +16 −0 benchmarks/Benchmarks.hs
  3. +13 −0 benchmarks/double-conversion-benchmarks.cabal
View
@@ -1,4 +1,4 @@
-^(?: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)$
~$
View
@@ -0,0 +1,16 @@
+{-# 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
+ ]
@@ -0,0 +1,13 @@
+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

0 comments on commit 72a3881

Please sign in to comment.