on master help sign in
Try with scientific too
commit139972e60f2582da6bdc94ec37cfb93414c524bb authorOleg Grenrus <oleg.grenrus@iki.fi> dateFri 12 Oct 2018, 12:06 (8 years ago) parent39d6516
2 files changed+20−9
benchmarks/Issue673.hs+19−9 benchmarks/aeson-benchmarks.cabal+1
benchmarks/Issue673.hs+19−9
@@ -17,6 +17,7 @@ module Main (
1717import Criterion.Main
1818import Prelude.Compat
1919import Data.Int (Int64)
20+import Data.Scientific (Scientific)
2021
2122import qualified Data.Aeson as A
2223import qualified Data.ByteString.Lazy as LBS
@@ -25,6 +26,9 @@ import qualified Data.ByteString.Lazy.Char8 as LBS8
2526decodeInt :: LBS.ByteString -> Maybe Int
2627decodeInt = A.decode
2728
29+decodeScientific :: LBS.ByteString -> Maybe Scientific
30+decodeScientific = A.decode
31+
2832generate :: Int64 -> LBS.ByteString
2933generate n = LBS8.replicate n '1'
3034
@@ -55,16 +59,22 @@ input8192 = generate 8192
5559input16384 :: LBS.ByteString
5660input16384 = generate 16384
5761
62+
5863main :: IO ()
5964main = defaultMain
6065 -- works on 64bit
61− [ bench "17" $ whnf decodeInt input17
62− -- , bench "32" $ whnf decodeInt input32
63− -- , bench "64" $ whnf decodeInt input64
64− -- , bench "128" $ whnf decodeInt input128
65− -- , bench "256" $ whnf decodeInt input256
66− , bench "2048" $ whnf decodeInt input2048
67− , bench "4096" $ whnf decodeInt input4096
68− , bench "8192" $ whnf decodeInt input8192
69− , bench "16384" $ whnf decodeInt input16384
66+ [ benchPair "17" input17
67+ -- , benchPair "32" input32
68+ -- , benchPair "64" input64
69+ -- , benchPair "128" input128
70+ -- , benchPair "256" input256
71+ , benchPair "2048" input2048
72+ , benchPair "4096" input4096
73+ , benchPair "8192" input8192
74+ , benchPair "16384" input16384
7075 ]
76+ where
77+ benchPair name input = bgroup name
78+ [ bench "Int" $ whnf decodeInt input
79+ , bench "Scientific" $ whnf decodeScientific input
80+ ]
benchmarks/aeson-benchmarks.cabal+1
@@ -335,5 +335,6 @@ executable aeson-issue-673
335335 aeson-benchmarks,
336336 base,
337337 bytestring,
338+ scientific,
338339 base-compat,
339340 criterion >= 1.0