on 1.2.2.0 help sign in
typeable/aeson/benchmarks/AesonTuples.hs
46 lines 1.1 kB history raw
1module Main (main) where
3import Prelude ()
4import Prelude.Compat
6import Control.DeepSeq (deepseq)
7import Criterion.Main
8import Data.Aeson
10--------------------------------------------------------------------------------
12type FJ a = Value -> Result a
14type T2 = (Int, Int)
15type T3 = (Int, Int, Int)
16type T4 = (Int, Int, Int, Int)
18t2 :: T2
19t2 = (1, 2)
21t3 :: T3
22t3 = (1, 2, 3)
24t4 :: T4
25t4 = (1, 2, 3, 4)
27main :: IO ()
28main = let v2 = toJSON t2
29 v3 = toJSON t3
30 v4 = toJSON t4
31 in t2 `deepseq` t3 `deepseq` t4 `deepseq`
32 v2 `deepseq` v3 `deepseq` v4 `deepseq`
33 defaultMain
34 [ bgroup "t2"
35 [ bench "toJSON" (nf toJSON t2)
36 , bench "fromJSON" (nf (fromJSON :: FJ T2) v2)
37 ]
38 , bgroup "t3"
39 [ bench "toJSON" (nf toJSON t3)
40 , bench "fromJSON" (nf (fromJSON :: FJ T3) v3)
41 ]
42 , bgroup "t4"
43 [ bench "toJSON" (nf toJSON t4)
44 , bench "fromJSON" (nf (fromJSON :: FJ T4) v4)
45 ]
46 ]