on master help sign in
enable pipe/sink/list benchmarks
commit8fbb4d422701b6d9ba7b5773a23d45357c0c6e46 authorHarendra Kumar <harendra.kumar@gmail.com> dateThu 26 Sep 2019, 01:05 (7 years ago) parente1ba45a
4 files changed+32−34
benchmark/Linear.hs+11−9 src/Streamly/Benchmark/Prelude.hs+6−10 src/Streamly/Internal/Data/Fold.hs+4−4 streamly.cabal+11−11
benchmark/Linear.hs+11−9
@@ -20,12 +20,14 @@ import qualified Streamly.Benchmark.Prelude as Ops
2020
2121import Streamly
2222import 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
2623import qualified Streamly.Memory.Array as A
2724import 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+
2931import Gauge
3032
3133-------------------------------------------------------------------------------
@@ -218,7 +220,7 @@ main =
218220 ]
219221 , bgroup "folds"
220222 [ benchIOSink "drain" (S.runFold FL.drain)
221− -- , benchIOSink "sink" (Sink.sink Sink.drain)
223+ , benchIOSink "sink" (S.runFold $ Sink.toFold Sink.drain)
222224 , benchIOSink "last" (S.runFold FL.last)
223225 , benchIOSink "length" (S.runFold FL.length)
224226 , benchIOSink "sum" (S.runFold FL.sum)
@@ -264,15 +266,15 @@ main =
264266 , bgroup "folds-transforms"
265267 [ benchIOSink "drain" (S.runFold FL.drain)
266268 , benchIOSink "lmap" (S.runFold (IFL.lmap (+1) FL.drain))
267− {-, benchIOSink "pipe-mapM"
268− (S.runFold (FL.transform (Pipe.mapM (\x -> return $ x + 1)) FL.drain))-}
269+ , benchIOSink "pipe-mapM"
270+ (S.runFold (IFL.transform (Pipe.mapM (\x -> return $ x + 1)) FL.drain))
269271 ]
270272 , bgroup "folds-compositions" -- Applicative
271273 [
272274 benchIOSink "all,any" (S.runFold ((,) <$> FL.all (<= Ops.maxValue)
273275 <*> FL.any (> Ops.maxValue)))
274276 , benchIOSink "sum,length" (S.runFold ((,) <$> FL.sum <*> FL.length))
275− ] {-
277+ ]
276278 , bgroup "pipes"
277279 [ benchIOSink "mapM" (Ops.transformMapM serially 1)
278280 , benchIOSink "compose" (Ops.transformComposeMapM serially 1)
@@ -284,7 +286,7 @@ main =
284286 , benchIOSink "compose" (Ops.transformComposeMapM serially 4)
285287 , benchIOSink "tee" (Ops.transformTeeMapM serially 4)
286288 , benchIOSink "zip" (Ops.transformZipMapM serially 4)
287− ] -}
289+ ]
288290 , bgroup "transformation"
289291 [ benchIOSink "scanl" (Ops.scan 1)
290292 , benchIOSink "scanl1'" (Ops.scanl1' 1)
src/Streamly/Benchmark/Prelude.hs+6−10
@@ -46,8 +46,8 @@ import qualified Streamly.Streams.StreamD as D
4646import qualified Streamly as S hiding (foldMapWith, runStream)
4747import qualified Streamly.Prelude as S
4848import qualified Streamly.Internal.Prelude as Internal
49−import qualified Streamly.Internal.Data.Unfold as UF
50−-- import qualified Streamly.Internal.Data.Pipe as Pipe
49+import qualified Streamly.Internal.Data.Unfold as UF
50+import qualified Streamly.Internal.Data.Pipe as Pipe
5151
5252value, maxValue, value2 :: Int
5353#ifdef LINEAR_ASYNC
@@ -411,9 +411,6 @@ map n = composeN n $ S.map (+1)
411411map' t n = composeN' n $ t . S.map (+1)
412412mapM t n = composeN' n $ t . S.mapM return
413413
414−-- Temporarily commented these ops as they depend on the hidden
415−-- Pipe module.
416−{-
417414{-# INLINE transformMapM #-}
418415{-# INLINE transformComposeMapM #-}
419416{-# INLINE transformTeeMapM #-}
@@ -423,17 +420,16 @@ transformMapM, transformComposeMapM, transformTeeMapM,
423420 transformZipMapM :: (S.IsStream t, S.MonadAsync m)
424421 => (t m Int -> S.SerialT m Int) -> Int -> t m Int -> m ()
425422
426−transformMapM t n = composeN' n $ t . S.transform (Pipe.mapM return)
427−transformComposeMapM t n = composeN' n $ t . S.transform
423+transformMapM t n = composeN' n $ t . Internal.transform (Pipe.mapM return)
424+transformComposeMapM t n = composeN' n $ t . Internal.transform
428425 (Pipe.mapM (\x -> return (x + 1))
429426 `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
431428 (Pipe.mapM (\x -> return (x + 1))
432429 `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
434431 (Pipe.zipWith (+) (Pipe.mapM (\x -> return (x + 1)))
435432 (Pipe.mapM (\x -> return (x + 2))))
436−-}
437433
438434mapMaybe n = composeN n $ S.mapMaybe
439435 (\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
113113 , mapM
114114
115115 -- ** Mapping
116− --, transform
116+ , transform
117117 , lmap
118118 --, lsequence
119119 , lmapM
@@ -285,9 +285,9 @@ mapM f = sequence . fmap f
285285-- | Apply a transformation on a 'Fold' using a 'Pipe'.
286286--
287287-- @since 0.7.0
288−{-# INLINE _transform #-}
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) =
288+{-# INLINE transform #-}
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) =
291291 Fold step initial extract
292292
293293 where
streamly.cabal+11−11
@@ -383,17 +383,17 @@ test-suite pure-streams-base
383383 , hspec >= 2.0 && < 3
384384 default-language: Haskell2010
385385
386−-- test-suite pure-streams-streamly
387−-- type: exitcode-stdio-1.0
388−-- import: test-options
389−-- main-is: PureStreams.hs
390−-- hs-source-dirs: test
391−-- cpp-options: -DUSE_STREAMLY_LIST
392−-- build-depends:
393−-- streamly
394−-- , base >= 4.8 && < 5
395−-- , hspec >= 2.0 && < 3
396−-- default-language: Haskell2010
386+test-suite pure-streams-streamly
387+ import: test-options
388+ type: exitcode-stdio-1.0
389+ main-is: PureStreams.hs
390+ hs-source-dirs: test
391+ cpp-options: -DUSE_STREAMLY_LIST
392+ build-depends:
393+ streamly
394+ , base >= 4.8 && < 5
395+ , hspec >= 2.0 && < 3
396+ default-language: Haskell2010
397397
398398test-suite properties
399399 import: test-options