Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
a54e958
Prepare to remove Streamly.Prelude benchmarks
harendra-kumar Nov 27, 2025
eed0a91
Remove Prelude.Ahead benchmark
harendra-kumar Nov 27, 2025
536cdc4
Remove Prelude.Async benchmark
harendra-kumar Nov 27, 2025
4dcbe6e
Remove Prelude.Parallel benchmark
harendra-kumar Nov 28, 2025
d48deaf
Remove Prelude.Rate
harendra-kumar Nov 28, 2025
39ec4d1
Remove Prelude.WAsync
harendra-kumar Nov 28, 2025
4128059
Remove Prelude.WSerial benchmark
harendra-kumar Nov 28, 2025
95c7782
Remove Prelude.Merge benchmark
harendra-kumar Nov 28, 2025
082bc57
Remove Prelude.ZipAsync benchmark
harendra-kumar Nov 28, 2025
1fe2d75
Remove Prelude.ZipSerial benchmark
harendra-kumar Nov 28, 2025
167fa17
Add monadic benchmarks for concurrent streams
harendra-kumar Nov 29, 2025
7284318
Cleanup, fix benchmarks for Data.Stream
harendra-kumar Nov 29, 2025
cc7bb73
Remove library used for Streamly.Prelude benchmarks
harendra-kumar Nov 29, 2025
f2c1eb2
Remove the removed benchmark targets from cabal file
harendra-kumar Nov 28, 2025
a05c01d
Reduce limit-build-mem for benchmarks to 400MB
harendra-kumar Nov 30, 2025
d35ef02
Remove obsolete bench-runner options, update Data.Stream options
harendra-kumar Nov 29, 2025
2038618
Remove Streamly.Prelude benchmarks from bench-runner targets
harendra-kumar Nov 29, 2025
e164e98
Create a streamly_core_grp benchmark group
harendra-kumar Nov 30, 2025
dd10117
Add ConcurrentOrdered, ConcurrentEager to hie.yaml
harendra-kumar Nov 29, 2025
7041f98
Remove Steramly.Prelude benchmark files from sdist
harendra-kumar Nov 30, 2025
891491d
Add hls.yaml to packcheck.ignore
harendra-kumar Nov 30, 2025
1d20bf1
Allow inspection-testing dep in nix flake
harendra-kumar Nov 30, 2025
ac4e73c
Update inspection-testing dep bound
harendra-kumar Nov 30, 2025
4481706
Fix hlint in StreamK benchmark
harendra-kumar Nov 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .packcheck.ignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ examples/README.md
flake.lock
flake.nix
hie.yaml
hls.yaml
packages.nix
sources.nix
stack.yaml
Expand Down
4 changes: 0 additions & 4 deletions benchmark/Streamly/Benchmark/Data/Stream.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ import qualified Stream.Expand as NestedStream
import qualified Stream.Generate as Generation
import qualified Stream.Lift as Lift
import qualified Stream.Reduce as NestedFold
#ifndef USE_PRELUDE
import qualified Stream.Split as Split
#endif
import qualified Stream.Transform as Transformation

import Streamly.Benchmark.Common
Expand Down Expand Up @@ -66,9 +64,7 @@ main = do
#ifndef USE_STREAMLY_CORE
, Exceptions.benchmarks moduleName env size
#endif
#ifndef USE_PRELUDE
, Split.benchmarks moduleName env
#endif
, Transformation.benchmarks moduleName size
, NestedFold.benchmarks moduleName size
, Lift.benchmarks moduleName size
Expand Down
87 changes: 15 additions & 72 deletions benchmark/Streamly/Benchmark/Data/Stream/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@
-- License : BSD-3-Clause
-- Maintainer : streamly@composewell.com

#ifdef USE_PRELUDE
#endif

module Stream.Common
( MonadAsync

-- Generation
, fromListM
, fromFoldableM
, repeat

, append
, append2
Expand All @@ -33,6 +31,7 @@ module Stream.Common
, sourceUnfoldrAction
, sourceConcatMapId
, sourceFromFoldable
, sourceFromFoldableM

-- Benchmark stream elimination
, benchIOSink
Expand Down Expand Up @@ -67,11 +66,9 @@ module Stream.Common
, transformComposeMapM
, transformTeeMapM
-- , transformZipMapM
#ifndef USE_PRELUDE
, scanMapM
, scanComposeMapM
, scanTeeMapM
#endif
)
where

Expand All @@ -88,81 +85,49 @@ import qualified Streamly.Internal.Data.Pipe as Pipe
import qualified Streamly.Internal.Data.Scanl as Scanl
import qualified Streamly.Internal.Data.Scanr as Scanr

#ifdef USE_PRELUDE
import Streamly.Prelude (foldl', scanl')
import qualified Streamly.Internal.Data.Stream.IsStream as Stream
import qualified Streamly.Prelude as Stream
import Streamly.Benchmark.Prelude
( composeN, sourceConcatMapId, benchIOSink
)
#else

import Streamly.Internal.Data.Stream (Stream)
import qualified Streamly.Internal.Data.Stream as D
import qualified Streamly.Internal.Data.Stream as Stream
#endif

import Test.Tasty.Bench
import Prelude hiding (Foldable(..), mapM, replicate)

#ifdef USE_PRELUDE
type Stream = Stream.SerialT
type MonadAsync m = Stream.MonadAsync m
mkCross = id
unCross = id
#else
import Prelude hiding (Foldable(..), mapM, replicate, repeat)

type MonadAsync = Monad

mkCross :: Stream m a -> Stream.Nested m a
mkCross = Stream.Nested

unCross :: Stream.Nested m a -> Stream m a
unCross = Stream.unNested
#endif

#ifdef USE_PRELUDE
{-# INLINE append #-}
append :: Monad m => Stream m a -> Stream m a -> Stream m a
append = Stream.serial
#else
append :: Monad m => Stream m a -> Stream m a -> Stream m a
append = Stream.append
#endif

{-# INLINE append2 #-}
append2 :: Monad m => Stream m a -> Stream m a -> Stream m a
#ifdef USE_PRELUDE
append2 = Stream.append
#else
append2 = D.append
#endif

{-# INLINE drain #-}
drain :: Monad m => Stream m a -> m ()
drain = Stream.drain

{-# INLINE toList #-}
toList :: Monad m => Stream m a -> m [a]
#ifdef USE_PRELUDE
drain = Stream.drain
toList = Stream.toList
#else
drain = Stream.fold Fold.drain
toList = Stream.fold Fold.toList
#endif

{-# INLINE repeat #-}
repeat :: Monad m => Int -> Int -> Stream m Int
repeat count = Stream.take count . Stream.repeat

{-# INLINE fromListM #-}
fromListM :: MonadAsync m => [m a] -> Stream m a
#ifdef USE_PRELUDE
fromListM = Stream.fromListM
#else
fromListM = Stream.sequence . Stream.fromList
#endif

{-# INLINE fromFoldableM #-}
fromFoldableM :: MonadAsync m => [m a] -> Stream m a
#ifdef USE_PRELUDE
fromFoldableM = Stream.fromFoldableM
#else
fromFoldableM = Stream.sequence . Stream.fromFoldable
#endif

{-# INLINE sourceUnfoldrM #-}
sourceUnfoldrM :: MonadAsync m => Int -> Int -> Stream m Int
Expand Down Expand Up @@ -201,7 +166,10 @@ sourceUnfoldrAction value n = Stream.unfoldr step n
sourceFromFoldable :: Monad m => Int -> Int -> Stream m Int
sourceFromFoldable value n = Stream.fromFoldable [n..n+value]

#ifndef USE_PRELUDE
{-# INLINE sourceFromFoldableM #-}
sourceFromFoldableM :: Monad m => Int -> Int -> Stream m Int
sourceFromFoldableM value n = Stream.fromFoldableM (fmap return [n..n+value])

{-# INLINE benchIOSink #-}
benchIOSink
:: (NFData b)
Expand All @@ -215,7 +183,6 @@ benchIOSinkPureSrc
=> Int -> String -> (Stream IO Int -> IO b) -> Benchmark
benchIOSinkPureSrc value name f =
bench name $ nfIO $ randomRIO (1,1) >>= f . sourceUnfoldr value
#endif

-- | Takes a source, and uses it with a default drain/fold method.
{-# INLINE benchIOSrc #-}
Expand All @@ -230,13 +197,11 @@ benchIOSrc name f =
benchIO :: (NFData b) => String -> (Int -> IO b) -> Benchmark
benchIO name f = bench name $ nfIO $ randomRIO (1,1) >>= f

#ifndef USE_PRELUDE
{-# INLINE sourceConcatMapId #-}
sourceConcatMapId :: (Monad m)
=> Int -> Int -> Stream m (Stream m Int)
sourceConcatMapId value n =
Stream.fromList $ fmap (D.fromEffect . return) [n..n+value]
#endif

{-# INLINE apDiscardFst #-}
apDiscardFst :: MonadAsync m =>
Expand Down Expand Up @@ -436,7 +401,6 @@ toListSome linearCount start =
where
nestedCount2 = round (fromIntegral linearCount**(1/2::Double))

#ifndef USE_PRELUDE
{-# INLINE composeN #-}
composeN ::
(Monad m)
Expand All @@ -451,7 +415,6 @@ composeN n f =
3 -> drain . f . f . f
4 -> drain . f . f . f . f
_ -> undefined
#endif

{-# INLINE mapN #-}
mapN ::
Expand All @@ -469,35 +432,27 @@ mapM ::
-> m ()
mapM n = composeN n $ Stream.mapM return

#ifndef USE_PRELUDE
foldl' :: Monad m => (b -> a -> b) -> b -> Stream m a -> m b
foldl' f z = Stream.fold (Fold.foldl' f z)

scanl' :: Monad m => (b -> a -> b) -> b -> Stream m a -> Stream m b
scanl' f z = Stream.scanl (Scanl.mkScanl f z)
#endif

{-# INLINE transformMapM #-}
transformMapM ::
(Monad m)
=> Int
-> Stream m Int
-> m ()
#ifndef USE_PRELUDE
transformMapM n = composeN n $ Stream.pipe (Pipe.mapM return)
#else
transformMapM n = composeN n $ Stream.transform (Pipe.mapM return)
#endif

#ifndef USE_PRELUDE
{-# INLINE scanMapM #-}
scanMapM ::
(Monad m)
=> Int
-> Stream m Int
-> m ()
scanMapM n = composeN n $ Stream.scanr (Scanr.functionM return)
#endif

{-# INLINE transformComposeMapM #-}
transformComposeMapM ::
Expand All @@ -507,15 +462,10 @@ transformComposeMapM ::
-> m ()
transformComposeMapM n =
composeN n $
#ifndef USE_PRELUDE
Stream.pipe
#else
Stream.transform
#endif
(Pipe.mapM (\x -> return (x + 1)) `Pipe.compose`
Pipe.mapM (\x -> return (x + 2)))

#ifndef USE_PRELUDE
{-# INLINE scanComposeMapM #-}
scanComposeMapM ::
(Monad m)
Expand All @@ -527,7 +477,6 @@ scanComposeMapM n =
Stream.scanr
(Scanr.functionM (\x -> return (x + 1)) `Scanr.compose`
Scanr.functionM (\x -> return (x + 2)))
#endif

{-# INLINE transformTeeMapM #-}
transformTeeMapM ::
Expand All @@ -537,15 +486,10 @@ transformTeeMapM ::
-> m ()
transformTeeMapM n =
composeN n $
#ifndef USE_PRELUDE
Stream.pipe
#else
Stream.transform
#endif
(Pipe.mapM (\x -> return (x + 1)) `Pipe.teeMerge`
Pipe.mapM (\x -> return (x + 2)))

#ifndef USE_PRELUDE
{-# INLINE scanTeeMapM #-}
scanTeeMapM ::
(Monad m)
Expand All @@ -557,7 +501,6 @@ scanTeeMapM n =
Stream.scanr
(Scanr.teeWith (+) (Scanr.functionM (\x -> return (x + 1)))
(Scanr.functionM (\x -> return (x + 2))))
#endif

{-
{-# INLINE transformZipMapM #-}
Expand Down
12 changes: 8 additions & 4 deletions benchmark/Streamly/Benchmark/Data/Stream/Concurrent.hs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{-# LANGUAGE FlexibleContexts #-}
-- |
--
-- Module : Main
-- Copyright : (c) 2018 Composewell Technologies
--
-- License : BSD3
-- Maintainer : streamly@composewell.com

import Stream.ConcurrentCommon (allBenchmarks)
import Stream.ConcurrentCommon
import Streamly.Benchmark.Common (runWithCLIOpts, defaultStreamSize)

moduleName :: String
Expand All @@ -17,4 +16,9 @@ moduleName = "Data.Stream.Concurrent"
-------------------------------------------------------------------------------

main :: IO ()
main = runWithCLIOpts defaultStreamSize (allBenchmarks moduleName False id)
main =
runWithCLIOpts
defaultStreamSize
(allBenchmarks
mkParallel
unParallel moduleName False id)
Loading
Loading