aeson / benchmarks / AesonTuples.hs

module Main where


import Criterion.Main
import Control.DeepSeq (deepseq)
import Data.Aeson


type FJ a = Value -> Result a

type T2 = (Int, Int)
type T3 = (Int, Int, Int)
type T4 = (Int, Int, Int, Int)

t2 :: T2
t2 = (1, 2)

t3 :: T3
t3 = (1, 2, 3)

t4 :: T4
t4 = (1, 2, 3, 4)

main :: IO ()
main = let v2 = toJSON t2
           v3 = toJSON t3
           v4 = toJSON t4
       in t2 `deepseq` t3 `deepseq` t4 `deepseq`
          v2 `deepseq` v3 `deepseq` v4 `deepseq`
              [ bgroup "t2"
                [ bench "toJSON"   (nf toJSON t2)
                , bench "fromJSON" (nf (fromJSON :: FJ T2) v2)
              , bgroup "t3"
                [ bench "toJSON"   (nf toJSON t3)
                , bench "fromJSON" (nf (fromJSON :: FJ T3) v3)
              , bgroup "t4"
                [ bench "toJSON"   (nf toJSON t4)
                , bench "fromJSON" (nf (fromJSON :: FJ T4) v4)
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
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.