on master help sign in
Add benchmarks for wAsync and parallel
3a3f8e7adithyaov
benchmark/Streamly/Benchmark/Prelude/Parallel.hs+22−1
@@ -116,6 +116,24 @@ o_n_heap_mapping value =
116 ]
116 ]
117 ]
117 ]
118
118
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+
119-------------------------------------------------------------------------------
137-------------------------------------------------------------------------------
120-- Concat
138-- Concat
121-------------------------------------------------------------------------------
139-------------------------------------------------------------------------------
@@ -197,7 +215,10 @@ main = do
197 where
215 where
198
216
199 allBenchmarks value =
217 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+ ]
201 , bgroup (o_n_heap_prefix moduleName) $ concat
222 , bgroup (o_n_heap_prefix moduleName) $ concat
202 [ o_n_heap_generation value
223 [ o_n_heap_generation value
203 , o_n_heap_mapping value
224 , o_n_heap_mapping value
benchmark/Streamly/Benchmark/Prelude/WAsync.hs+38
@@ -49,6 +49,43 @@ o_1_space_mapping value =
49 ]
49 ]
50 ]
50 ]
51
51
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+
52-------------------------------------------------------------------------------
89-------------------------------------------------------------------------------
53-- Concat
90-- Concat
54-------------------------------------------------------------------------------
91-------------------------------------------------------------------------------
@@ -140,6 +177,7 @@ main = do
140 [ bgroup (o_1_space_prefix moduleName) $ concat
177 [ bgroup (o_1_space_prefix moduleName) $ concat
141 [ o_1_space_generation value
178 [ o_1_space_generation value
142 , o_1_space_mapping value
179 , o_1_space_mapping value
180+ , o_1_space_joining value
143 , o_1_space_concatFoldable value
181 , o_1_space_concatFoldable value
144 , o_1_space_concatMap value
182 , o_1_space_concatMap value
145 ]
183 ]