on e7d2a73 help sign in
streamly/benchmark/Nested.hs
96 lines 4.3 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 [ bgroup "serially"
26 [ benchIO "toNullAp" $ Ops.toNullAp serially
27 , benchIO "toNull" $ Ops.toNull serially
28 , benchIO "toNull3" $ Ops.toNull3 serially
29 , benchIO "toList" $ Ops.toList serially
30 -- , benchIO "toListSome" $ Ops.toListSome serially
31 , benchIO "filterAllOut" $ Ops.filterAllOut serially
32 , benchIO "filterAllIn" $ Ops.filterAllIn serially
33 , benchIO "filterSome" $ Ops.filterSome serially
34 , benchIO "breakAfterSome" $ Ops.breakAfterSome serially
35 ]
37 , bgroup "wSerially"
38 [ benchIO "toNullAp" $ Ops.toNullAp wSerially
39 , benchIO "toNull" $ Ops.toNull wSerially
40 , benchIO "toNull3" $ Ops.toNull3 wSerially
41 , benchIO "toList" $ Ops.toList wSerially
42 -- , benchIO "toListSome" $ Ops.toListSome wSerially
43 , benchIO "filterAllOut" $ Ops.filterAllOut wSerially
44 , benchIO "filterAllIn" $ Ops.filterAllIn wSerially
45 , benchIO "filterSome" $ Ops.filterSome wSerially
46 , benchIO "breakAfterSome" $ Ops.breakAfterSome wSerially
47 ]
49 , bgroup "aheadly"
50 [ benchIO "toNullAp" $ Ops.toNullAp aheadly
51 , benchIO "toNull" $ Ops.toNull aheadly
52 , benchIO "toNull3" $ Ops.toNull3 aheadly
53 , benchIO "toList" $ Ops.toList aheadly
54 -- , benchIO "toListSome" $ Ops.toListSome aheadly
55 , benchIO "filterAllOut" $ Ops.filterAllOut aheadly
56 , benchIO "filterAllIn" $ Ops.filterAllIn aheadly
57 , benchIO "filterSome" $ Ops.filterSome aheadly
58 , benchIO "breakAfterSome" $ Ops.breakAfterSome aheadly
59 ]
61 , bgroup "asyncly"
62 [ benchIO "toNullAp" $ Ops.toNullAp asyncly
63 , benchIO "toNull" $ Ops.toNull asyncly
64 , benchIO "toNull3" $ Ops.toNull3 asyncly
65 , benchIO "toList" $ Ops.toList asyncly
66 -- , benchIO "toListSome" $ Ops.toListSome asyncly
67 , benchIO "filterAllOut" $ Ops.filterAllOut asyncly
68 , benchIO "filterAllIn" $ Ops.filterAllIn asyncly
69 , benchIO "filterSome" $ Ops.filterSome asyncly
70 , benchIO "breakAfterSome" $ Ops.breakAfterSome asyncly
71 ]
73 , bgroup "wAsyncly"
74 [ benchIO "toNullAp" $ Ops.toNullAp wAsyncly
75 , benchIO "toNull" $ Ops.toNull wAsyncly
76 , benchIO "toNull3" $ Ops.toNull3 wAsyncly
77 , benchIO "toList" $ Ops.toList wAsyncly
78 -- , benchIO "toListSome" $ Ops.toListSome wAsyncly
79 , benchIO "filterAllOut" $ Ops.filterAllOut wAsyncly
80 , benchIO "filterAllIn" $ Ops.filterAllIn wAsyncly
81 , benchIO "filterSome" $ Ops.filterSome wAsyncly
82 , benchIO "breakAfterSome" $ Ops.breakAfterSome wAsyncly
83 ]
85 , bgroup "parallely"
86 [ benchIO "toNullAp" $ Ops.toNullAp parallely
87 , benchIO "toNull" $ Ops.toNull parallely
88 , benchIO "toNull3" $ Ops.toNull3 parallely
89 , benchIO "toList" $ Ops.toList parallely
90 --, benchIO "toListSome" $ Ops.toListSome parallely
91 , benchIO "filterAllOut" $ Ops.filterAllOut parallely
92 , benchIO "filterAllIn" $ Ops.filterAllIn parallely
93 , benchIO "filterSome" $ Ops.filterSome parallely
94 , benchIO "breakAfterSome" $ Ops.breakAfterSome parallely
95 ]
96 ]