Skip to content

Commit

Permalink
Reorganize benchmarks a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
tibbe committed Feb 25, 2013
1 parent 1621a58 commit c1af44f
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions benchmarks/Benchmarks.hs
Expand Up @@ -30,6 +30,9 @@ data President = President
, homeState :: !Text
}

instance NFData President where
rnf (President {}) = ()

instance FromRecord President where
parseRecord v
| V.length v == 7 = President <$>
Expand Down Expand Up @@ -103,6 +106,10 @@ main = do
[ bgroup "decode"
[ bench "presidents/without conversion" $ whnf idDecode csvData
, bench "presidents/with conversion" $ whnf decodePresidents csvData
, bgroup "streaming"
[ bench "presidents/without conversion" $ nf idDecodeS csvData
, bench "presidents/with conversion" $ nf decodePresidentsS csvData
]
]
, bgroup "encode"
[ bench "presidents/with conversion" $ whnf encode presidents
Expand All @@ -118,9 +125,7 @@ main = do
]
]
, bgroup "comparison"
[ bench "cassava" $ nf idDecode csvData
, bench "cassava/streaming" $ nf idDecodeS csvData
, bench "lazy-csv" $ nf LazyCsv.parseCSV csvData
[ bench "lazy-csv" $ nf LazyCsv.parseCSV csvData
]
]
where
Expand All @@ -130,6 +135,9 @@ main = do
decodePresidentsN :: BL.ByteString -> Either String (Header, Vector President)
decodePresidentsN = decodeByName

decodePresidentsS :: BL.ByteString -> Streaming.Records President
decodePresidentsS = Streaming.decode False

idDecode :: BL.ByteString -> Either String (Vector (Vector B.ByteString))
idDecode = decode False

Expand Down

0 comments on commit c1af44f

Please sign in to comment.