on cee86ff help sign in
streamly/benchmark/NestedConcurrent.hs
73 lines 3.1 kB history raw
1-- |
2-- Module : Main
3-- Copyright : (c) 2018 Harendra Kumar
4--
5-- License : BSD3
6-- Maintainer : streamly@composewell.com
8import Control.DeepSeq (NFData)
9import Data.Functor.Identity (Identity, runIdentity)
10import System.Random (randomRIO)
12import Common (parseCLIOpts)
14import Streamly
15import Gauge
17import qualified NestedOps as Ops
19benchIO :: (NFData b) => String -> (Int -> IO b) -> Benchmark
20benchIO name f = bench name $ nfIO $ randomRIO (1,1) >>= f
22_benchId :: (NFData b) => String -> (Int -> Identity b) -> Benchmark
23_benchId name f = bench name $ nf (\g -> runIdentity (g 1)) f
25defaultStreamSize :: Int
26defaultStreamSize = 100000
28main :: IO ()
29main = do
30 -- XXX Fix indentation
31 (linearCount, cfg, benches) <- parseCLIOpts defaultStreamSize
32 linearCount `seq` runMode (mode cfg) cfg benches
33 [
34 bgroup "aheadly"
35 [ benchIO "toNullAp" $ Ops.toNullAp linearCount aheadly
36 , benchIO "toNull" $ Ops.toNull linearCount aheadly
37 , benchIO "toNull3" $ Ops.toNull3 linearCount aheadly
38 -- , benchIO "toList" $ Ops.toList linearCount aheadly
39 , benchIO "toListSome" $ Ops.toListSome linearCount aheadly
40 , benchIO "filterAllOut" $ Ops.filterAllOut linearCount aheadly
41 , benchIO "filterAllIn" $ Ops.filterAllIn linearCount aheadly
42 , benchIO "filterSome" $ Ops.filterSome linearCount aheadly
43 , benchIO "breakAfterSome" $ Ops.breakAfterSome linearCount aheadly
44 ]
46 , bgroup "asyncly"
47 [ benchIO "toNullAp" $ Ops.toNullAp linearCount asyncly
48 , benchIO "toNull" $ Ops.toNull linearCount asyncly
49 , benchIO "toNull3" $ Ops.toNull3 linearCount asyncly
50 -- , benchIO "toList" $ Ops.toList linearCount asyncly
51 , benchIO "toListSome" $ Ops.toListSome linearCount asyncly
52 , benchIO "filterAllOut" $ Ops.filterAllOut linearCount asyncly
53 , benchIO "filterAllIn" $ Ops.filterAllIn linearCount asyncly
54 , benchIO "filterSome" $ Ops.filterSome linearCount asyncly
55 , benchIO "breakAfterSome" $ Ops.breakAfterSome linearCount asyncly
56 ]
58 , bgroup "wAsyncly"
59 [ benchIO "toNullAp" $ Ops.toNullAp linearCount wAsyncly
60 , benchIO "toNull" $ Ops.toNull linearCount wAsyncly
61 , benchIO "toNull3" $ Ops.toNull3 linearCount wAsyncly
62 -- , benchIO "toList" $ Ops.toList linearCount wAsyncly
63 , benchIO "toListSome" $ Ops.toListSome linearCount wAsyncly
64 , benchIO "filterAllOut" $ Ops.filterAllOut linearCount wAsyncly
65 , benchIO "filterAllIn" $ Ops.filterAllIn linearCount wAsyncly
66 , benchIO "filterSome" $ Ops.filterSome linearCount wAsyncly
67 , benchIO "breakAfterSome" $ Ops.breakAfterSome linearCount wAsyncly
68 ]
70 , bgroup "zipAsyncly"
71 [ benchIO "toNullAp" $ Ops.toNullAp linearCount zipAsyncly
72 ]
73 ]