on master help sign in
Add some nested benchmarks with parseMany
commit195606428c672c8c283f757b20a2eb57816242ff authorAdithya Kumar <adithya@composewell.com> dateSun 14 Feb 2021, 00:43 (6 years ago) parent30ea7f1
1 file changed+30
benchmark/Streamly/Benchmark/Data/Parser/ParserD.hs+30
benchmark/Streamly/Benchmark/Data/Parser/ParserD.hs+30
@@ -192,6 +192,23 @@ spanByRolling :: MonadThrow m => Int -> SerialT m Int -> m ((), ())
192192spanByRolling value =
193193 IP.parseD (PR.spanByRolling (\_ i -> i <= value `div` 2) FL.drain FL.drain)
194194
195+-------------------------------------------------------------------------------
196+-- Nested
197+-------------------------------------------------------------------------------
198+
199+{-# INLINE parseMany #-}
200+parseMany :: MonadThrow m => Int -> SerialT m Int -> m ()
201+parseMany value = IP.drain . IP.parseManyD (drainWhile (<= value + 1))
202+
203+{-# INLINE parseManyGroups #-}
204+parseManyGroups :: MonadThrow m => Bool -> SerialT m Int -> m ()
205+parseManyGroups b = IP.drain . IP.parseManyD (PR.groupBy (\_ _ -> b) FL.drain)
206+
207+{-# INLINE parseManyGroupsRolling #-}
208+parseManyGroupsRolling :: MonadThrow m => Bool -> SerialT m Int -> m ()
209+parseManyGroupsRolling b =
210+ IP.drain . IP.parseManyD (PR.groupByRolling (\_ _ -> b) FL.drain)
211+
195212-------------------------------------------------------------------------------
196213-- Parsers in which -fspec-constr-recursive=16 is problematic
197214-------------------------------------------------------------------------------
@@ -276,6 +293,18 @@ o_1_space_serial_spanning value =
276293 , benchIOSink value "spanByRolling" $ spanByRolling value
277294 ]
278295
296+o_1_space_serial_nested :: Int -> [Benchmark]
297+o_1_space_serial_nested value =
298+ [ benchIOSink value "parseMany" $ parseMany value
299+ , benchIOSink value "parseMany groupBy (bound groups)"
300+ $ (parseManyGroups False)
301+ , benchIOSink value "parseMany groupRollingBy (bound groups)"
302+ $ (parseManyGroupsRolling False)
303+ , benchIOSink value "parseMany groupBy (1 group)" $ (parseManyGroups True)
304+ , benchIOSink value "parseMany groupRollingBy (1 group)"
305+ $ (parseManyGroupsRolling True)
306+ ]
307+
279308o_n_heap_serial :: Int -> [Benchmark]
280309o_n_heap_serial value =
281310 [
@@ -312,6 +341,7 @@ main = do
312341 allBenchmarks value =
313342 [ bgroup (o_1_space_prefix moduleName) (o_1_space_serial value)
314343 , bgroup (o_1_space_prefix moduleName) (o_1_space_serial_spanning value)
344+ , bgroup (o_1_space_prefix moduleName) (o_1_space_serial_nested value)
315345 , bgroup (o_n_heap_prefix moduleName) (o_n_heap_serial value)
316346 , bgroup (o_n_space_prefix moduleName) (o_n_space_serial value)
317347 ]