@@ -15,7 +15,7 @@ import Data.Monoid (Last(..), Sum(..))
15import System.Random (randomRIO)
15import System.Random (randomRIO)
16import Prelude (IO, Int, Double, String, (>), (<*>), (<$>), (+), ($),
16import Prelude (IO, Int, Double, String, (>), (<*>), (<$>), (+), ($),
17 (<=), Monad(..), (==), Maybe(..), (.), fromIntegral,
17 (<=), Monad(..), (==), Maybe(..), (.), fromIntegral,
18− compare, (>=), concat, seq)
18+ compare, (>=), concat, seq, Either(..), odd)
20import qualified Streamly.Prelude as S
20import qualified Streamly.Prelude as S
21import qualified Streamly.Internal.Data.Fold as FL
21import qualified Streamly.Internal.Data.Fold as FL
@@ -66,6 +66,7 @@ o_1_space_serial_elimination value =
66 [ bgroup "serially"
66 [ bgroup "serially"
67 [ bgroup "elimination"
67 [ bgroup "elimination"
68 [ benchIOSink value "drain" (S.fold FL.drain)
68 [ benchIOSink value "drain" (S.fold FL.drain)
69+ , benchIOSink value "drainBy" (S.fold (FL.drainBy return))
69 , benchIOSink value "drainN" (S.fold (IFL.drainN value))
70 , benchIOSink value "drainN" (S.fold (IFL.drainN value))
70 , benchIOSink
71 , benchIOSink
@@ -116,9 +117,17 @@ o_1_space_serial_elimination value =
117 "foldMap"
118 "foldMap"
118 (S.fold (FL.foldMap (Last . Just)))
119 (S.fold (FL.foldMap (Last . Just)))
123+ (S.fold (FL.foldMapM (return . Last . Just)))
119 , benchIOSink value "index" (S.fold (FL.index (value + 1)))
124 , benchIOSink value "index" (S.fold (FL.index (value + 1)))
120 , benchIOSink value "head" (S.fold FL.head)
125 , benchIOSink value "head" (S.fold FL.head)
121 , benchIOSink value "find" (S.fold (FL.find (== (value + 1))))
126 , benchIOSink value "find" (S.fold (FL.find (== (value + 1))))
130+ (S.fold (IFL.lmap (\a -> (a, a)) (FL.lookup (value + 1))))
122 , benchIOSink
131 , benchIOSink
124 "findIndex"
133 "findIndex"
@@ -150,6 +159,11 @@ o_1_space_serial_transformation value =
150 [ bgroup "serially"
159 [ bgroup "serially"
151 [ bgroup "transformation"
160 [ bgroup "transformation"
152 [ benchIOSink value "lmap" (S.fold (IFL.lmap (+ 1) FL.drain))
161 [ benchIOSink value "lmap" (S.fold (IFL.lmap (+ 1) FL.drain))
165+ (S.fold (FL.sequence (return <$> FL.drain)))
166+ , benchIOSink value "mapM" (S.fold (FL.mapM return FL.drain))
153 , benchIOSink
167 , benchIOSink
155 "pipe-mapM"
169 "pipe-mapM"
@@ -175,6 +189,24 @@ o_1_space_serial_composition value =
176 "sum,length"
190 "sum,length"
177 (S.fold ((,) <$> FL.sum <*> FL.length))
191 (S.fold ((,) <$> FL.sum <*> FL.length))
195+ (S.fold (FL.tee FL.sum FL.length))
198+ "distribute sum length"
199+ (S.fold (FL.distribute [FL.sum, FL.length]))
202+ "partition sum length"
204+ (\a -> if odd a then Left a else Right a)
205+ (FL.partition FL.sum FL.length)))
209+ (S.fold (IFL.lmap (\a -> (a, a)) (FL.unzip FL.sum FL.length)))