@@ -27,7 +27,7 @@ import qualified Streamly.Prelude as S
28import Gauge
28import Gauge
29import Streamly.Benchmark.Common
29import Streamly.Benchmark.Common
30−import Prelude hiding (all, any, take, unzip)
30+import Prelude hiding (all, any, take, unzip, sequence_)
32-- We need a monadic bind here to make sure that the function f does not get
32-- We need a monadic bind here to make sure that the function f does not get
33-- completely optimized out by the compiler in some cases.
33-- completely optimized out by the compiler in some cases.
@@ -68,6 +68,15 @@ all value = IP.fold (FL.all (<= value))
68takeLE :: Monad m => Int -> SerialT m a -> m ()
68takeLE :: Monad m => Int -> SerialT m a -> m ()
69takeLE value = IP.fold (FL.takeLE value FL.drain)
69takeLE value = IP.fold (FL.takeLE value FL.drain)
71+{-# INLINE sequence_ #-}
72+sequence_ :: Monad m => Int -> Fold m a ()
73+sequence_ value = foldr f (pure ()) (Prelude.replicate value (FL.takeLE 1 FL.drain))
78+ f m k = FL.concatMap (const k) m
71-------------------------------------------------------------------------------
80-------------------------------------------------------------------------------
72-- Splitting by serial application
81-- Splitting by serial application
73-------------------------------------------------------------------------------
82-------------------------------------------------------------------------------
@@ -284,6 +293,11 @@ o_1_space_serial_composition value =
285 mp = Map.fromList [(0, FL.sum), (1, FL.length)]
294 mp = Map.fromList [(0, FL.sum), (1, FL.length)]
296+o_n_space_serial :: Int -> [Benchmark]
297+o_n_space_serial value =
298+ [ benchIOSink value "sequence_/100" $ S.fold (sequence_ (value `div` 100))
287o_n_heap_serial :: Int -> [Benchmark]
301o_n_heap_serial :: Int -> [Benchmark]
288o_n_heap_serial value =
302o_n_heap_serial value =
289 [ bgroup "elimination"
303 [ bgroup "elimination"
@@ -312,5 +326,6 @@ main = do
312 , o_1_space_serial_transformation value
326 , o_1_space_serial_transformation value
313 , o_1_space_serial_composition value
327 , o_1_space_serial_composition value
329+ , bgroup (o_n_space_prefix moduleName) (o_n_space_serial value)
315 , bgroup (o_n_heap_prefix moduleName) (o_n_heap_serial value)
330 , bgroup (o_n_heap_prefix moduleName) (o_n_heap_serial value)