on f5c55df help sign in
streamly/benchmark/NestedUnfold.hs
38 lines 1.2 kB history raw
1-- |
2-- Module : NestedUnfold
3-- Copyright : (c) 2019 Composewell Technologies
4--
5-- License : BSD3
6-- Maintainer : streamly@composewell.com
8import Control.DeepSeq (NFData)
9import System.Random (randomRIO)
11import Common (parseCLIOpts)
13import qualified NestedUnfoldOps as Ops
15import Gauge
17benchIO :: (NFData b) => String -> (Int -> IO b) -> Benchmark
18benchIO name f = bench name $ nfIO $ randomRIO (1,1) >>= f
20defaultStreamSize :: Int
21defaultStreamSize = 100000
23main :: IO ()
24main = do
25 (linearCount, cfg, benches) <- parseCLIOpts defaultStreamSize
26 linearCount `seq` runMode (mode cfg) cfg benches
27 [ bgroup "unfold"
28 [ benchIO "toNull" $ Ops.toNull linearCount
29 , benchIO "toNull3" $ Ops.toNull3 linearCount
30 , benchIO "concat" $ Ops.concat linearCount
31 -- , benchIO "toList" $ Ops.toList
32 , benchIO "toListSome" $ Ops.toListSome linearCount
33 , benchIO "filterAllOut" $ Ops.filterAllOut linearCount
34 , benchIO "filterAllIn" $ Ops.filterAllIn linearCount
35 , benchIO "filterSome" $ Ops.filterSome linearCount
36 , benchIO "breakAfterSome" $ Ops.breakAfterSome linearCount
37 ]
38 ]