Commits

Bryan O'Sullivan  committed 2dc41d3

Backport Bas's number benchmarks

  • Participants
  • Parent commits 62a0e3a

Comments (0)

Files changed (1)

File benchmarks/Benchmarks.hs

        bench "short" $ nf (AB.parse quotedString) (BC.pack "abcdefghijk\"")
      , bench "long" $ nf (AB.parse quotedString) b
      ]
+
+   , let strN     = "1234.56789"
+         strNePos = "1234.56789e3"
+         strNeNeg = "1234.56789e-3"
+     in
+     bgroup "numbers"
+     [ let !tN     = T.pack strN
+           !tNePos = T.pack strNePos
+           !tNeNeg = T.pack strNeNeg
+       in bgroup "Text"
+       [
+         bgroup "no power"
+         [ bench "double"     $ nf (AT.parseOnly AT.double)                            tN
+         , bench "number"     $ nf (AT.parseOnly AT.number)                            tN
+         , bench "rational"   $ nf (AT.parseOnly (AT.rational :: AT.Parser Rational))  tN
+         ]
+       , bgroup "positive power"
+         [ bench "double"     $ nf (AT.parseOnly AT.double)                            tNePos
+         , bench "number"     $ nf (AT.parseOnly AT.number)                            tNePos
+         , bench "rational"   $ nf (AT.parseOnly (AT.rational :: AT.Parser Rational))  tNePos
+         ]
+       , bgroup "negative power"
+         [ bench "double"     $ nf (AT.parseOnly AT.double)                            tNeNeg
+         , bench "number"     $ nf (AT.parseOnly AT.number)                            tNeNeg
+         , bench "rational"   $ nf (AT.parseOnly (AT.rational :: AT.Parser Rational))  tNeNeg
+         ]
+       ]
+     , let !bN     = BC.pack strN
+           !bNePos = BC.pack strNePos
+           !bNeNeg = BC.pack strNeNeg
+       in bgroup "ByteString"
+       [ bgroup "no power"
+         [ bench "double"     $ nf (AC.parseOnly AC.double)                             bN
+         , bench "number"     $ nf (AC.parseOnly AC.number)                             bN
+         , bench "rational"   $ nf (AC.parseOnly (AC.rational :: AC.Parser Rational))   bN
+         ]
+       , bgroup "positive power"
+         [ bench "double"     $ nf (AC.parseOnly AC.double)                             bNePos
+         , bench "number"     $ nf (AC.parseOnly AC.number)                             bNePos
+         , bench "rational"   $ nf (AC.parseOnly (AC.rational :: AC.Parser Rational))   bNePos
+         ]
+       , bgroup "negative power"
+         [ bench "double"     $ nf (AC.parseOnly AC.double)                             bNeNeg
+         , bench "number"     $ nf (AC.parseOnly AC.number)                             bNeNeg
+         , bench "rational"   $ nf (AC.parseOnly (AC.rational :: AC.Parser Rational))   bNeNeg
+         ]
+       ]
+     ]
    ]
 
 -- Benchmarks bind and (potential) bounds-check merging.