on 2c77298 help sign in
streamly/benchmark/NestedConcurrent.hs
85 lines 3.7 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 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 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 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 "parallely"
71 [ benchIO "toNullAp" $ Ops.toNullAp linearCount parallely
72 , benchIO "toNull" $ Ops.toNull linearCount parallely
73 , benchIO "toNull3" $ Ops.toNull3 linearCount parallely
74 , benchIO "toList" $ Ops.toList linearCount parallely
75 --, benchIO "toListSome" $ Ops.toListSome parallely
76 , benchIO "filterAllOut" $ Ops.filterAllOut linearCount parallely
77 , benchIO "filterAllIn" $ Ops.filterAllIn linearCount parallely
78 , benchIO "filterSome" $ Ops.filterSome linearCount parallely
79 , benchIO "breakAfterSome" $ Ops.breakAfterSome linearCount parallely
80 ]
82 , bgroup "zipAsyncly"
83 [ benchIO "toNullAp" $ Ops.toNullAp linearCount zipAsyncly
84 ]
85 ]