on master help sign in
Benchmark both strict and lazy decoding
commita25235e2b27d05b9dafab4c7ad6d6f608e3ed814 authorBryan O'Sullivan <bos@serpentine.com> dateFri 10 Jul 2015, 15:26 (11 years ago) parent674bd71
1 file changed+7−1
benchmarks/CompareWithJSON.hs+7−1
benchmarks/CompareWithJSON.hs+7−1
@@ -34,6 +34,11 @@ decodeA s = case A.decode s of
3434 Just v -> v
3535 Nothing -> error "fail to parse via Aeson"
3636
37+decodeA' :: BL.ByteString -> A.Value
38+decodeA' s = case A.decode' s of
39+ Just v -> v
40+ Nothing -> error "fail to parse via Aeson"
41+
3742encodeJ :: J.JSValue -> BL.ByteString
3843encodeJ = toLazyByteString . fromString . J.encode
3944
@@ -54,7 +59,8 @@ main = do
5459 defaultMain [
5560 bgroup "decode" [
5661 bgroup "en" [
57− bench "aeson" $ nf decodeA enA
62+ bench "aeson/lazy" $ nf decodeA enA
63+ , bench "aeson/strict" $ nf decodeA' enA
5864 , bench "json" $ nf decodeJ enJ
5965 ]
6066 , bgroup "jp" [