Commits

Bryan O'Sullivan committed 51e7330

Benchmark decimal integer rendering

Comments (0)

Files changed (2)

benchmarks/haskell/Benchmarks/Builder.hs

 import qualified Data.Text as T
 import qualified Data.Text.Lazy as LT
 import qualified Data.Text.Lazy.Builder as LTB
+import qualified Data.Text.Lazy.Builder.Int as Int
 
 benchmark :: IO Benchmark
 benchmark = return $ bgroup "Builder"
-    [ bench "LazyText" $ nf
-        (LT.length . LTB.toLazyText . mconcat . map LTB.fromText) texts
-    , bench "Binary" $ nf
-        (LB.length . B.toLazyByteString . mconcat . map B.fromByteString)
-        byteStrings
-    , bench "Blaze" $ nf
-        (LB.length . Blaze.toLazyByteString . mconcat . map Blaze.fromString)
-        strings
+    [ bgroup "Comparison"
+      [ bench "LazyText" $ nf
+          (LT.length . LTB.toLazyText . mconcat . map LTB.fromText) texts
+      , bench "Binary" $ nf
+          (LB.length . B.toLazyByteString . mconcat . map B.fromByteString)
+          byteStrings
+      , bench "Blaze" $ nf
+          (LB.length . Blaze.toLazyByteString . mconcat . map Blaze.fromString)
+          strings
+      ]
+    , bgroup "Int"
+      [ bgroup "Decimal"
+        [ bgroup "Positive" .
+          flip map numbers $ \n ->
+          (bench (show n) $ nf (LTB.toLazyText . Int.decimal) n)
+        , bgroup "Negative" .
+          flip map numbers $ \m ->
+          let n = negate m in
+          (bench (show n) $ nf (LTB.toLazyText . Int.decimal) n)
+        ]
+      ]
     ]
+  where
+    numbers = [6,1,14,93,500,415,9688,2865,10654,30214,795659,829056,6207351,
+               5608880,33929478,96076286,370106126,731223504] :: [Int]
 
 texts :: [T.Text]
 texts = take 200000 $ cycle ["foo", "λx", "由の"]

benchmarks/text-benchmarks.cabal

                   cbits/time_iconv.c
   main-is:        Benchmarks.hs
   ghc-options:    -Wall -O2
-  cpp-options:    -DHAVE_DEEPSEQ
+  cpp-options:    -DHAVE_DEEPSEQ -DINTEGER_GMP
   build-depends:  base == 4.*,
                   binary,
                   blaze-builder,
                   directory,
                   filepath,
                   ghc-prim,
+                  integer-gmp,
                   stringsearch,
                   utf8-string
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.