on 6cd235f help sign in
streamly/benchmark/Nested.hs
90 lines 3.9 kB history raw
1-- |
2-- Module : Main
3-- Copyright : (c) 2018 Harendra Kumar
4--
5-- License : BSD3
6-- Maintainer : harendra.kumar@gmail.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 "toList" $ Ops.toList serially
29 -- , benchIO "toListSome" $ Ops.toListSome serially
30 , benchIO "filterAllOut" $ Ops.filterAllOut serially
31 , benchIO "filterAllIn" $ Ops.filterAllIn serially
32 , benchIO "filterSome" $ Ops.filterSome serially
33 , benchIO "breakAfterSome" $ Ops.breakAfterSome serially
34 ]
36 , bgroup "wSerially"
37 [ benchIO "toNullAp" $ Ops.toNullAp wSerially
38 , benchIO "toNull" $ Ops.toNull wSerially
39 , benchIO "toList" $ Ops.toList wSerially
40 -- , benchIO "toListSome" $ Ops.toListSome wSerially
41 , benchIO "filterAllOut" $ Ops.filterAllOut wSerially
42 , benchIO "filterAllIn" $ Ops.filterAllIn wSerially
43 , benchIO "filterSome" $ Ops.filterSome wSerially
44 , benchIO "breakAfterSome" $ Ops.breakAfterSome wSerially
45 ]
47 , bgroup "aheadly"
48 [ benchIO "toNullAp" $ Ops.toNullAp aheadly
49 , benchIO "toNull" $ Ops.toNull aheadly
50 , benchIO "toList" $ Ops.toList aheadly
51 -- , benchIO "toListSome" $ Ops.toListSome aheadly
52 , benchIO "filterAllOut" $ Ops.filterAllOut aheadly
53 , benchIO "filterAllIn" $ Ops.filterAllIn aheadly
54 , benchIO "filterSome" $ Ops.filterSome aheadly
55 , benchIO "breakAfterSome" $ Ops.breakAfterSome aheadly
56 ]
58 , bgroup "asyncly"
59 [ benchIO "toNullAp" $ Ops.toNullAp asyncly
60 , benchIO "toNull" $ Ops.toNull asyncly
61 , benchIO "toList" $ Ops.toList asyncly
62 -- , benchIO "toListSome" $ Ops.toListSome asyncly
63 , benchIO "filterAllOut" $ Ops.filterAllOut asyncly
64 , benchIO "filterAllIn" $ Ops.filterAllIn asyncly
65 , benchIO "filterSome" $ Ops.filterSome asyncly
66 , benchIO "breakAfterSome" $ Ops.breakAfterSome asyncly
67 ]
69 , bgroup "wAsyncly"
70 [ benchIO "toNullAp" $ Ops.toNullAp wAsyncly
71 , benchIO "toNull" $ Ops.toNull wAsyncly
72 , benchIO "toList" $ Ops.toList wAsyncly
73 -- , benchIO "toListSome" $ Ops.toListSome wAsyncly
74 , benchIO "filterAllOut" $ Ops.filterAllOut wAsyncly
75 , benchIO "filterAllIn" $ Ops.filterAllIn wAsyncly
76 , benchIO "filterSome" $ Ops.filterSome wAsyncly
77 , benchIO "breakAfterSome" $ Ops.breakAfterSome wAsyncly
78 ]
80 , bgroup "parallely"
81 [ benchIO "toNullAp" $ Ops.toNullAp parallely
82 , benchIO "toNull" $ Ops.toNull parallely
83 , benchIO "toList" $ Ops.toList parallely
84 --, benchIO "toListSome" $ Ops.toListSome parallely
85 , benchIO "filterAllOut" $ Ops.filterAllOut parallely
86 , benchIO "filterAllIn" $ Ops.filterAllIn parallely
87 , benchIO "filterSome" $ Ops.filterSome parallely
88 , benchIO "breakAfterSome" $ Ops.breakAfterSome parallely
89 ]
90 ]