on master help sign in
enable pipe/sink/list benchmarks
8fbb4d4Harendra Kumar
benchmark/Linear.hs+11−9
@@ -20,12 +20,14 @@ import qualified Streamly.Benchmark.Prelude as Ops
20
20
21import Streamly
21import Streamly
22import qualified Streamly.Data.Fold as FL
22import qualified Streamly.Data.Fold as FL
23−import qualified Streamly.Internal.Data.Fold.Types as IFL
24−import qualified Streamly.Internal.Prelude as IP
25−--import qualified Streamly.Internal.Data.Pipe as Pipe
26import qualified Streamly.Memory.Array as A
23import qualified Streamly.Memory.Array as A
27import qualified Streamly.Prelude as S
24import qualified Streamly.Prelude as S
28−-- import qualified Streamly.Internal.Data.Sink as Sink
25+import qualified Streamly.Internal.Data.Sink as Sink
26+
27+import qualified Streamly.Internal.Data.Fold as IFL
28+import qualified Streamly.Internal.Prelude as IP
29+import qualified Streamly.Internal.Data.Pipe as Pipe
30+
29import Gauge
31import Gauge
30
32
31-------------------------------------------------------------------------------
33-------------------------------------------------------------------------------
@@ -218,7 +220,7 @@ main =
218 ]
220 ]
219 , bgroup "folds"
221 , bgroup "folds"
220 [ benchIOSink "drain" (S.runFold FL.drain)
222 [ benchIOSink "drain" (S.runFold FL.drain)
221− -- , benchIOSink "sink" (Sink.sink Sink.drain)
223+ , benchIOSink "sink" (S.runFold $ Sink.toFold Sink.drain)
222 , benchIOSink "last" (S.runFold FL.last)
224 , benchIOSink "last" (S.runFold FL.last)
223 , benchIOSink "length" (S.runFold FL.length)
225 , benchIOSink "length" (S.runFold FL.length)
224 , benchIOSink "sum" (S.runFold FL.sum)
226 , benchIOSink "sum" (S.runFold FL.sum)
@@ -264,15 +266,15 @@ main =
264 , bgroup "folds-transforms"
266 , bgroup "folds-transforms"
265 [ benchIOSink "drain" (S.runFold FL.drain)
267 [ benchIOSink "drain" (S.runFold FL.drain)
266 , benchIOSink "lmap" (S.runFold (IFL.lmap (+1) FL.drain))
268 , benchIOSink "lmap" (S.runFold (IFL.lmap (+1) FL.drain))
267− {-, benchIOSink "pipe-mapM"
269+ , benchIOSink "pipe-mapM"
268− (S.runFold (FL.transform (Pipe.mapM (\x -> return $ x + 1)) FL.drain))-}
270+ (S.runFold (IFL.transform (Pipe.mapM (\x -> return $ x + 1)) FL.drain))
269 ]
271 ]
270 , bgroup "folds-compositions" -- Applicative
272 , bgroup "folds-compositions" -- Applicative
271 [
273 [
272 benchIOSink "all,any" (S.runFold ((,) <$> FL.all (<= Ops.maxValue)
274 benchIOSink "all,any" (S.runFold ((,) <$> FL.all (<= Ops.maxValue)
273 <*> FL.any (> Ops.maxValue)))
275 <*> FL.any (> Ops.maxValue)))
274 , benchIOSink "sum,length" (S.runFold ((,) <$> FL.sum <*> FL.length))
276 , benchIOSink "sum,length" (S.runFold ((,) <$> FL.sum <*> FL.length))
275− ] {-
277+ ]
276 , bgroup "pipes"
278 , bgroup "pipes"
277 [ benchIOSink "mapM" (Ops.transformMapM serially 1)
279 [ benchIOSink "mapM" (Ops.transformMapM serially 1)
278 , benchIOSink "compose" (Ops.transformComposeMapM serially 1)
280 , benchIOSink "compose" (Ops.transformComposeMapM serially 1)
@@ -284,7 +286,7 @@ main =
284 , benchIOSink "compose" (Ops.transformComposeMapM serially 4)
286 , benchIOSink "compose" (Ops.transformComposeMapM serially 4)
285 , benchIOSink "tee" (Ops.transformTeeMapM serially 4)
287 , benchIOSink "tee" (Ops.transformTeeMapM serially 4)
286 , benchIOSink "zip" (Ops.transformZipMapM serially 4)
288 , benchIOSink "zip" (Ops.transformZipMapM serially 4)
287− ] -}
289+ ]
288 , bgroup "transformation"
290 , bgroup "transformation"
289 [ benchIOSink "scanl" (Ops.scan 1)
291 [ benchIOSink "scanl" (Ops.scan 1)
290 , benchIOSink "scanl1'" (Ops.scanl1' 1)
292 , benchIOSink "scanl1'" (Ops.scanl1' 1)
src/Streamly/Benchmark/Prelude.hs+6−10
@@ -46,8 +46,8 @@ import qualified Streamly.Streams.StreamD as D
46import qualified Streamly as S hiding (foldMapWith, runStream)
46import qualified Streamly as S hiding (foldMapWith, runStream)
47import qualified Streamly.Prelude as S
47import qualified Streamly.Prelude as S
48import qualified Streamly.Internal.Prelude as Internal
48import qualified Streamly.Internal.Prelude as Internal
49−import qualified Streamly.Internal.Data.Unfold as UF
49+import qualified Streamly.Internal.Data.Unfold as UF
50−-- import qualified Streamly.Internal.Data.Pipe as Pipe
50+import qualified Streamly.Internal.Data.Pipe as Pipe
51
51
52value, maxValue, value2 :: Int
52value, maxValue, value2 :: Int
53#ifdef LINEAR_ASYNC
53#ifdef LINEAR_ASYNC
@@ -411,9 +411,6 @@ map n = composeN n $ S.map (+1)
411map' t n = composeN' n $ t . S.map (+1)
411map' t n = composeN' n $ t . S.map (+1)
412mapM t n = composeN' n $ t . S.mapM return
412mapM t n = composeN' n $ t . S.mapM return
413
413
414−-- Temporarily commented these ops as they depend on the hidden
415−-- Pipe module.
416−{-
417{-# INLINE transformMapM #-}
414{-# INLINE transformMapM #-}
418{-# INLINE transformComposeMapM #-}
415{-# INLINE transformComposeMapM #-}
419{-# INLINE transformTeeMapM #-}
416{-# INLINE transformTeeMapM #-}
@@ -423,17 +420,16 @@ transformMapM, transformComposeMapM, transformTeeMapM,
423 transformZipMapM :: (S.IsStream t, S.MonadAsync m)
420 transformZipMapM :: (S.IsStream t, S.MonadAsync m)
424 => (t m Int -> S.SerialT m Int) -> Int -> t m Int -> m ()
421 => (t m Int -> S.SerialT m Int) -> Int -> t m Int -> m ()
425
422
426−transformMapM t n = composeN' n $ t . S.transform (Pipe.mapM return)
423+transformMapM t n = composeN' n $ t . Internal.transform (Pipe.mapM return)
427−transformComposeMapM t n = composeN' n $ t . S.transform
424+transformComposeMapM t n = composeN' n $ t . Internal.transform
428 (Pipe.mapM (\x -> return (x + 1))
425 (Pipe.mapM (\x -> return (x + 1))
429 `Pipe.compose` Pipe.mapM (\x -> return (x + 2)))
426 `Pipe.compose` Pipe.mapM (\x -> return (x + 2)))
430−transformTeeMapM t n = composeN' n $ t . S.transform
427+transformTeeMapM t n = composeN' n $ t . Internal.transform
431 (Pipe.mapM (\x -> return (x + 1))
428 (Pipe.mapM (\x -> return (x + 1))
432 `Pipe.tee` Pipe.mapM (\x -> return (x + 2)))
429 `Pipe.tee` Pipe.mapM (\x -> return (x + 2)))
433−transformZipMapM t n = composeN' n $ t . S.transform
430+transformZipMapM t n = composeN' n $ t . Internal.transform
434 (Pipe.zipWith (+) (Pipe.mapM (\x -> return (x + 1)))
431 (Pipe.zipWith (+) (Pipe.mapM (\x -> return (x + 1)))
435 (Pipe.mapM (\x -> return (x + 2))))
432 (Pipe.mapM (\x -> return (x + 2))))
436−-}
437
433
438mapMaybe n = composeN n $ S.mapMaybe
434mapMaybe n = composeN n $ S.mapMaybe
439 (\x -> if Prelude.odd x then Nothing else Just x)
435 (\x -> if Prelude.odd x then Nothing else Just x)
src/Streamly/Internal/Data/Fold.hs+4−4
@@ -113,7 +113,7 @@ module Streamly.Internal.Data.Fold
113 , mapM
113 , mapM
114
114
115 -- ** Mapping
115 -- ** Mapping
116− --, transform
116+ , transform
117 , lmap
117 , lmap
118 --, lsequence
118 --, lsequence
119 , lmapM
119 , lmapM
@@ -285,9 +285,9 @@ mapM f = sequence . fmap f
285-- | Apply a transformation on a 'Fold' using a 'Pipe'.
285-- | Apply a transformation on a 'Fold' using a 'Pipe'.
286--
286--
287-- @since 0.7.0
287-- @since 0.7.0
288−{-# INLINE _transform #-}
288+{-# INLINE transform #-}
289−_transform :: Monad m => Pipe m a b -> Fold m b c -> Fold m a c
289+transform :: Monad m => Pipe m a b -> Fold m b c -> Fold m a c
290−_transform (Pipe pstep1 pstep2 pinitial) (Fold fstep finitial fextract) =
290+transform (Pipe pstep1 pstep2 pinitial) (Fold fstep finitial fextract) =
291 Fold step initial extract
291 Fold step initial extract
292
292
293 where
293 where
streamly.cabal+11−11
@@ -383,17 +383,17 @@ test-suite pure-streams-base
383 , hspec >= 2.0 && < 3
383 , hspec >= 2.0 && < 3
384 default-language: Haskell2010
384 default-language: Haskell2010
385
385
386−-- test-suite pure-streams-streamly
386+test-suite pure-streams-streamly
387+ import: test-options
387−-- type: exitcode-stdio-1.0
388+ type: exitcode-stdio-1.0
388−-- import: test-options
389−-- main-is: PureStreams.hs
389+ main-is: PureStreams.hs
390−-- hs-source-dirs: test
390+ hs-source-dirs: test
391−-- cpp-options: -DUSE_STREAMLY_LIST
391+ cpp-options: -DUSE_STREAMLY_LIST
392−-- build-depends:
392+ build-depends:
393−-- streamly
393+ streamly
394−-- , base >= 4.8 && < 5
394+ , base >= 4.8 && < 5
395−-- , hspec >= 2.0 && < 3
395+ , hspec >= 2.0 && < 3
396−-- default-language: Haskell2010
396+ default-language: Haskell2010
397
397
398test-suite properties
398test-suite properties
399 import: test-options
399 import: test-options