1{-# LANGUAGE BangPatterns #-}
2{-# OPTIONS_GHC -fno-warn-deprecations #-}
4module Numbers (numbers) where
6import Criterion.Main (bench, bgroup, nf)
7import Criterion.Types (Benchmark)
8import Data.Scientific (Scientific(..))
9import Text.Parsec.Text ()
10import Text.Parsec.Text.Lazy ()
11import qualified Data.Attoparsec.ByteString.Char8 as AC
12import qualified Data.Attoparsec.Text as AT
13import qualified Data.ByteString.Char8 as BC
14import qualified Data.Text as T
16strN, strNePos, strNeNeg :: String
18strNePos = "1234.56789e3"
19strNeNeg = "1234.56789e-3"
22numbers = bgroup "numbers" [
24 !tNePos = T.pack strNePos
25 !tNeNeg = T.pack strNeNeg
29 [ bench "double" $ nf (AT.parseOnly AT.double) tN
30 , bench "number" $ nf (AT.parseOnly AT.number) tN
32 nf (AT.parseOnly (AT.rational :: AT.Parser Rational)) tN
33 , bench "scientific" $
34 nf (AT.parseOnly (AT.rational :: AT.Parser Scientific)) tN
36 , bgroup "positive power"
37 [ bench "double" $ nf (AT.parseOnly AT.double) tNePos
38 , bench "number" $ nf (AT.parseOnly AT.number) tNePos
40 nf (AT.parseOnly (AT.rational :: AT.Parser Rational)) tNePos
41 , bench "scientific" $
42 nf (AT.parseOnly (AT.rational :: AT.Parser Scientific)) tNePos
44 , bgroup "negative power"
45 [ bench "double" $ nf (AT.parseOnly AT.double) tNeNeg
46 , bench "number" $ nf (AT.parseOnly AT.number) tNeNeg
48 nf (AT.parseOnly (AT.rational :: AT.Parser Rational)) tNeNeg
49 , bench "scientific" $
50 nf (AT.parseOnly (AT.rational :: AT.Parser Scientific)) tNeNeg
53 , let !bN = BC.pack strN
54 !bNePos = BC.pack strNePos
55 !bNeNeg = BC.pack strNeNeg
56 in bgroup "ByteString"
58 [ bench "double" $ nf (AC.parseOnly AC.double) bN
59 , bench "number" $ nf (AC.parseOnly AC.number) bN
61 nf (AC.parseOnly (AC.rational :: AC.Parser Rational)) bN
62 , bench "scientific" $
63 nf (AC.parseOnly (AC.rational :: AC.Parser Scientific)) bN
65 , bgroup "positive power"
66 [ bench "double" $ nf (AC.parseOnly AC.double) bNePos
67 , bench "number" $ nf (AC.parseOnly AC.number) bNePos
69 nf (AC.parseOnly (AC.rational :: AC.Parser Rational)) bNePos
70 , bench "scientific" $
71 nf (AC.parseOnly (AC.rational :: AC.Parser Scientific)) bNePos
73 , bgroup "negative power"
74 [ bench "double" $ nf (AC.parseOnly AC.double) bNeNeg
75 , bench "number" $ nf (AC.parseOnly AC.number) bNeNeg
77 nf (AC.parseOnly (AC.rational :: AC.Parser Rational)) bNeNeg
78 , bench "scientific" $
79 nf (AC.parseOnly (AC.rational :: AC.Parser Scientific)) bNeNeg
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list