Skip to content

Commit

Permalink
Add criterion-based benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
bos committed Jun 27, 2011
1 parent 50f2c5b commit 72a3881
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .hgignore
@@ -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)$
~$
Expand Down
16 changes: 16 additions & 0 deletions benchmarks/Benchmarks.hs
@@ -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
]
13 changes: 13 additions & 0 deletions benchmarks/double-conversion-benchmarks.cabal
@@ -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.