on 511fe85 help sign in
streamly/benchmark/NestedConcurrent.hs
77 lines 3.2 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)
11import qualified NestedOps as Ops
12import Streamly
13import Gauge
15benchIO :: (NFData b) => String -> (Int -> IO b) -> Benchmark
16benchIO name f = bench name $ nfIO $ randomRIO (1,1) >>= f
18_benchId :: (NFData b) => String -> (Int -> Identity b) -> Benchmark
19_benchId name f = bench name $ nf (\g -> runIdentity (g 1)) f
21main :: IO ()
22main =
23 -- TBD Study scaling with 10, 100, 1000 loop iterations
24 defaultMain
25 [
26 bgroup "aheadly"
27 [ benchIO "toNullAp" $ Ops.toNullAp aheadly
28 , benchIO "toNull" $ Ops.toNull aheadly
29 , benchIO "toNull3" $ Ops.toNull3 aheadly
30 , benchIO "toList" $ Ops.toList aheadly
31 -- , benchIO "toListSome" $ Ops.toListSome aheadly
32 , benchIO "filterAllOut" $ Ops.filterAllOut aheadly
33 , benchIO "filterAllIn" $ Ops.filterAllIn aheadly
34 , benchIO "filterSome" $ Ops.filterSome aheadly
35 , benchIO "breakAfterSome" $ Ops.breakAfterSome aheadly
36 ]
38 , bgroup "asyncly"
39 [ benchIO "toNullAp" $ Ops.toNullAp asyncly
40 , benchIO "toNull" $ Ops.toNull asyncly
41 , benchIO "toNull3" $ Ops.toNull3 asyncly
42 , benchIO "toList" $ Ops.toList asyncly
43 -- , benchIO "toListSome" $ Ops.toListSome asyncly
44 , benchIO "filterAllOut" $ Ops.filterAllOut asyncly
45 , benchIO "filterAllIn" $ Ops.filterAllIn asyncly
46 , benchIO "filterSome" $ Ops.filterSome asyncly
47 , benchIO "breakAfterSome" $ Ops.breakAfterSome asyncly
48 ]
50 , bgroup "wAsyncly"
51 [ benchIO "toNullAp" $ Ops.toNullAp wAsyncly
52 , benchIO "toNull" $ Ops.toNull wAsyncly
53 , benchIO "toNull3" $ Ops.toNull3 wAsyncly
54 , benchIO "toList" $ Ops.toList wAsyncly
55 -- , benchIO "toListSome" $ Ops.toListSome wAsyncly
56 , benchIO "filterAllOut" $ Ops.filterAllOut wAsyncly
57 , benchIO "filterAllIn" $ Ops.filterAllIn wAsyncly
58 , benchIO "filterSome" $ Ops.filterSome wAsyncly
59 , benchIO "breakAfterSome" $ Ops.breakAfterSome wAsyncly
60 ]
62 , bgroup "parallely"
63 [ benchIO "toNullAp" $ Ops.toNullAp parallely
64 , benchIO "toNull" $ Ops.toNull parallely
65 , benchIO "toNull3" $ Ops.toNull3 parallely
66 , benchIO "toList" $ Ops.toList parallely
67 --, benchIO "toListSome" $ Ops.toListSome parallely
68 , benchIO "filterAllOut" $ Ops.filterAllOut parallely
69 , benchIO "filterAllIn" $ Ops.filterAllIn parallely
70 , benchIO "filterSome" $ Ops.filterSome parallely
71 , benchIO "breakAfterSome" $ Ops.breakAfterSome parallely
72 ]
74 , bgroup "zipAsyncly"
75 [ benchIO "toNullAp" $ Ops.toNullAp zipAsyncly
76 ]
77 ]