Bryan O'Sullivan avatar Bryan O'Sullivan committed 717caff

Make benchmarks more comprehensive.

Comments (0)

Files changed (1)

benchmarks/CompareWithJSON.hs

               Just v -> v
               Nothing -> error "fail to parse via Aeson"
 
-jsonData :: FilePath
-jsonData = "json-data/jp100.json"
-
 main :: IO ()
 main = do
-  js <- readFile jsonData
-  as <- BL.readFile jsonData
-  let jdata = decodeJ js
-      adata = decodeA as
+  let enFile = "json-data/twitter100.json"
+      jpFile = "json-data/jp100.json"
+  enA <- BL.readFile enFile
+  enJ <- readFile enFile
+  jpA <- BL.readFile jpFile
+  jpJ <- readFile jpFile
   defaultMain [
-        bgroup "decode" [ bench "json"  $ nf decodeJ js
-                        , bench "aeson" $ nf decodeA as
-                        ],
-        bgroup "encode" [ bench "json"  $ nf J.encode jdata
-                        , bench "aeson" $ nf A.encode adata
-                        ]
-       ]
+      bgroup "decode" [
+        bgroup "en" [
+          bench "aeson" $ nf decodeA enA
+        , bench "json"  $ nf decodeJ enJ
+        ]
+      , bgroup "jp" [
+          bench "aeson" $ nf decodeA jpA
+        , bench "json"  $ nf decodeJ jpJ
+        ]
+      ]
+    , bgroup "encode" [
+        bgroup "en" [
+          bench "aeson" $ nf A.encode (decodeA enA)
+        , bench "json"  $ nf J.encode (decodeJ enJ)
+        ]
+      , bgroup "jp" [
+          bench "aeson" $ nf A.encode (decodeA jpA)
+        , bench "json"  $ nf J.encode (decodeJ jpJ)
+        ]
+      ]
+    ]
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.