@@ -46,11 +46,13 @@ decodeA s = case A.decode s of
46encodeJ :: J.JSValue -> BL.ByteString
46encodeJ :: J.JSValue -> BL.ByteString
47encodeJ = toLazyByteString . fromString . J.encode
47encodeJ = toLazyByteString . fromString . J.encode
49+#if MIN_VERSION_bytestring(0,10,4)
49encodeToText :: A.Value -> TL.Text
50encodeToText :: A.Value -> TL.Text
50encodeToText = TLB.toLazyText . A.encodeToTextBuilder . A.toJSON
51encodeToText = TLB.toLazyText . A.encodeToTextBuilder . A.toJSON
52encodeViaText :: A.Value -> BL.ByteString
53encodeViaText :: A.Value -> BL.ByteString
53encodeViaText = TLE.encodeUtf8 . encodeToText
54encodeViaText = TLE.encodeUtf8 . encodeToText
55main :: IO ()
57main :: IO ()
@@ -74,14 +76,18 @@ main = do
74 , bgroup "encode" [
76 , bgroup "encode" [
75 bgroup "en" [
77 bgroup "en" [
76 bench "aeson-to-bytestring" $ nf A.encode (decodeA enA)
78 bench "aeson-to-bytestring" $ nf A.encode (decodeA enA)
79+#if MIN_VERSION_bytestring(0,10,4)
77 , bench "aeson-via-text-to-bytestring" $ nf encodeViaText (decodeA enA)
80 , bench "aeson-via-text-to-bytestring" $ nf encodeViaText (decodeA enA)
78 , bench "aeson-to-text" $ nf encodeToText (decodeA enA)
81 , bench "aeson-to-text" $ nf encodeToText (decodeA enA)
79 , bench "json" $ nf encodeJ (decodeJ enJ)
83 , bench "json" $ nf encodeJ (decodeJ enJ)
81 , bgroup "jp" [
85 , bgroup "jp" [
82 bench "aeson-to-bytestring" $ nf A.encode (decodeA jpA)
86 bench "aeson-to-bytestring" $ nf A.encode (decodeA jpA)
87+#if MIN_VERSION_bytestring(0,10,4)
83 , bench "aeson-via-text-to-bytestring" $ nf encodeViaText (decodeA jpA)
88 , bench "aeson-via-text-to-bytestring" $ nf encodeViaText (decodeA jpA)
84 , bench "aeson-to-text" $ nf encodeToText (decodeA jpA)
89 , bench "aeson-to-text" $ nf encodeToText (decodeA jpA)
85 , bench "json" $ nf encodeJ (decodeJ jpJ)
91 , bench "json" $ nf encodeJ (decodeJ jpJ)