on master help sign in
Add benchmarks for wAsync and parallel
commit3a3f8e740000b54dc24eeef2bf6cc1986b264280 authoradithyaov <adithya@composewell.com> dateMon 23 Nov 2020, 13:51 (6 years ago) parent06b230f
2 files changed+60−1
benchmark/Streamly/Benchmark/Prelude/Parallel.hs+22−1 benchmark/Streamly/Benchmark/Prelude/WAsync.hs+38
benchmark/Streamly/Benchmark/Prelude/Parallel.hs+22−1
@@ -116,6 +116,24 @@ o_n_heap_mapping value =
116116 ]
117117 ]
118118
119+
120+-------------------------------------------------------------------------------
121+-- Joining
122+-------------------------------------------------------------------------------
123+
124+{-# INLINE parallel2 #-}
125+parallel2 :: Int -> Int -> IO ()
126+parallel2 count n =
127+ S.drain $
128+ (sourceUnfoldrM count n) `parallel` (sourceUnfoldrM count (n + 1))
129+
130+o_1_space_joining :: Int -> [Benchmark]
131+o_1_space_joining value =
132+ [ bgroup "joining"
133+ [ benchIOSrc1 "parallel (2 of n/2)" (parallel2 (value `div` 2))
134+ ]
135+ ]
136+
119137-------------------------------------------------------------------------------
120138-- Concat
121139-------------------------------------------------------------------------------
@@ -197,7 +215,10 @@ main = do
197215 where
198216
199217 allBenchmarks value =
200− [ bgroup (o_1_space_prefix moduleName) (o_1_space_merge_app_tap value)
218+ [ bgroup (o_1_space_prefix moduleName) $ concat
219+ [ o_1_space_merge_app_tap value
220+ , o_1_space_joining value
221+ ]
201222 , bgroup (o_n_heap_prefix moduleName) $ concat
202223 [ o_n_heap_generation value
203224 , o_n_heap_mapping value
benchmark/Streamly/Benchmark/Prelude/WAsync.hs+38
@@ -49,6 +49,43 @@ o_1_space_mapping value =
4949 ]
5050 ]
5151
52+-------------------------------------------------------------------------------
53+-- Joining
54+-------------------------------------------------------------------------------
55+
56+{-# INLINE wAsync2 #-}
57+wAsync2 :: Int -> Int -> IO ()
58+wAsync2 count n =
59+ S.drain $
60+ (sourceUnfoldrM count n) `wAsync` (sourceUnfoldrM count (n + 1))
61+
62+{-# INLINE wAsync4 #-}
63+wAsync4 :: Int -> Int -> IO ()
64+wAsync4 count n =
65+ S.drain $
66+ (sourceUnfoldrM count (n + 0))
67+ `wAsync` (sourceUnfoldrM count (n + 1))
68+ `wAsync` (sourceUnfoldrM count (n + 2))
69+ `wAsync` (sourceUnfoldrM count (n + 3))
70+
71+{-# INLINE wAsync2n2 #-}
72+wAsync2n2 :: Int -> Int -> IO ()
73+wAsync2n2 count n =
74+ S.drain $
75+ ((sourceUnfoldrM count (n + 0))
76+ `wAsync` (sourceUnfoldrM count (n + 1)))
77+ `wAsync` ((sourceUnfoldrM count (n + 2))
78+ `wAsync` (sourceUnfoldrM count (n + 3)))
79+
80+o_1_space_joining :: Int -> [Benchmark]
81+o_1_space_joining value =
82+ [ bgroup "joining"
83+ [ benchIOSrc1 "wAsync (2 of n/2)" (wAsync2 (value `div` 2))
84+ , benchIOSrc1 "wAsync (4 of n/4)" (wAsync4 (value `div` 4))
85+ , benchIOSrc1 "wAsync (2 of (2 of n/4)" (wAsync2n2 (value `div` 4))
86+ ]
87+ ]
88+
5289-------------------------------------------------------------------------------
5390-- Concat
5491-------------------------------------------------------------------------------
@@ -140,6 +177,7 @@ main = do
140177 [ bgroup (o_1_space_prefix moduleName) $ concat
141178 [ o_1_space_generation value
142179 , o_1_space_mapping value
180+ , o_1_space_joining value
143181 , o_1_space_concatFoldable value
144182 , o_1_space_concatMap value
145183 ]