on master help sign in
Make Data.Stream benchmark build with streamly-core
a14c058Harendra Kumar
benchmark/Streamly/Benchmark/Data/Stream/Common.hs+6−1
@@ -34,6 +34,7 @@ module Stream.Common
34 -- Benchmark stream elimination
34 -- Benchmark stream elimination
35 , benchIOSink
35 , benchIOSink
36 , benchIOSrc
36 , benchIOSrc
37+ , benchIO
37
38
38 -- Benchmarking functions
39 -- Benchmarking functions
39 , concatStreamsWith
40 , concatStreamsWith
@@ -62,6 +63,7 @@ module Stream.Common
62where
63where
63
64
64import Control.Applicative (liftA2)
65import Control.Applicative (liftA2)
66+import Control.DeepSeq (NFData)
65import Control.Exception (try)
67import Control.Exception (try)
66import GHC.Exception (ErrorCall)
68import GHC.Exception (ErrorCall)
67import Streamly.Internal.Data.Stream (Stream)
69import Streamly.Internal.Data.Stream (Stream)
@@ -79,7 +81,6 @@ import Streamly.Benchmark.Prelude
79 , concatStreamsWith, concatPairsWith
81 , concatStreamsWith, concatPairsWith
80 )
82 )
81#else
83#else
82−import Control.DeepSeq (NFData)
83import qualified Streamly.Internal.Data.Stream as Stream
84import qualified Streamly.Internal.Data.Stream as Stream
84#endif
85#endif
85
86
@@ -183,6 +184,10 @@ benchIOSrc
183benchIOSrc name f =
184benchIOSrc name f =
184 bench name $ nfIO $ randomRIO (1,1) >>= drain . f
185 bench name $ nfIO $ randomRIO (1,1) >>= drain . f
185
186
187+{-# NOINLINE benchIO #-}
188+benchIO :: (NFData b) => String -> (Int -> IO b) -> Benchmark
189+benchIO name f = bench name $ nfIO $ randomRIO (1,1) >>= f
190+
186#ifndef USE_PRELUDE
191#ifndef USE_PRELUDE
187{-# INLINE concatStreamsWith #-}
192{-# INLINE concatStreamsWith #-}
188concatStreamsWith
193concatStreamsWith
benchmark/Streamly/Benchmark/Data/Stream/Exceptions.hs+20−8
@@ -21,17 +21,22 @@
21
21
22module Stream.Exceptions (benchmarks) where
22module Stream.Exceptions (benchmarks) where
23
23
24−import Control.Exception (SomeException, Exception, throwIO)
24+import Control.Exception (Exception, throwIO)
25import Stream.Common (drain)
25import Stream.Common (drain)
26import Streamly.Internal.Data.Stream (Stream)
26import Streamly.Internal.Data.Stream (Stream)
27−import System.IO (Handle, hClose, hPutChar)
28
27
29import qualified Data.IORef as Ref
28import qualified Data.IORef as Ref
30import qualified Data.Map.Strict as Map
29import qualified Data.Map.Strict as Map
31import qualified Stream.Common as Common
30import qualified Stream.Common as Common
31+
32+#ifndef USE_STREAMLY_CORE
33+import Control.Exception (SomeException)
34+import System.IO (Handle, hClose, hPutChar)
32import qualified Streamly.FileSystem.Handle as FH
35import qualified Streamly.FileSystem.Handle as FH
33−import qualified Streamly.Internal.Data.Unfold as IUF
34import qualified Streamly.Internal.FileSystem.Handle as IFH
36import qualified Streamly.Internal.FileSystem.Handle as IFH
37+import qualified Streamly.Internal.Data.Unfold as IUF
38+#endif
39+
35#ifdef USE_PRELUDE
40#ifdef USE_PRELUDE
36import qualified Streamly.Internal.Data.Stream.IsStream as Stream
41import qualified Streamly.Internal.Data.Stream.IsStream as Stream
37#else
42#else
@@ -134,6 +139,9 @@ o_1_space_serial_exceptions length =
134 ]
139 ]
135 ]
140 ]
136
141
142+-- XXX Move these to FileSystem.Handle benchmarks
143+#ifndef USE_STREAMLY_CORE
144+
137-------------------------------------------------------------------------------
145-------------------------------------------------------------------------------
138-- copy stream exceptions
146-- copy stream exceptions
139-------------------------------------------------------------------------------
147-------------------------------------------------------------------------------
@@ -323,12 +331,16 @@ o_1_space_copy_exceptions_toChunks env =
323 ]
331 ]
324 ]
332 ]
325
333
334+#endif
335+
326benchmarks :: String -> BenchEnv -> Int -> [Benchmark]
336benchmarks :: String -> BenchEnv -> Int -> [Benchmark]
327−benchmarks moduleName env size =
337+benchmarks moduleName _env size =
328 [ bgroup (o_1_space_prefix moduleName) $ concat
338 [ bgroup (o_1_space_prefix moduleName) $ concat
339+ [ o_1_space_serial_exceptions size
340+#ifndef USE_STREAMLY_CORE
329− [ o_1_space_copy_exceptions_readChunks env
341+ , o_1_space_copy_exceptions_readChunks _env
330− , o_1_space_copy_exceptions_toChunks env
342+ , o_1_space_copy_exceptions_toChunks _env
331− , o_1_space_copy_stream_exceptions env
343+ , o_1_space_copy_stream_exceptions _env
332− , o_1_space_serial_exceptions size
344+#endif
333 ]
345 ]
334 ]
346 ]
benchmark/Streamly/Benchmark/Data/Stream/Expand.hs−1
@@ -32,7 +32,6 @@ import Test.Inspection
32import qualified Streamly.Internal.Data.Stream.StreamD as D
32import qualified Streamly.Internal.Data.Stream.StreamD as D
33#endif
33#endif
34
34
35−import Streamly.Benchmark.Prelude (benchIO)
36import qualified Stream.Common as Common
35import qualified Stream.Common as Common
37#ifdef USE_PRELUDE
36#ifdef USE_PRELUDE
38import qualified Streamly.Internal.Data.Stream.IsStream as S
37import qualified Streamly.Internal.Data.Stream.IsStream as S
benchmark/Streamly/Benchmark/Data/Stream/Lift.hs+2−4
@@ -15,14 +15,12 @@ import Control.DeepSeq (NFData(..))
15import Control.Monad.Trans.Class (lift)
15import Control.Monad.Trans.Class (lift)
16import Control.Monad.State.Strict (StateT, get, put, MonadState)
16import Control.Monad.State.Strict (StateT, get, put, MonadState)
17import Data.Functor.Identity (Identity)
17import Data.Functor.Identity (Identity)
18+import Stream.Common
18−import Stream.Common (sourceUnfoldr, sourceUnfoldrM, benchIOSrc, drain)
19+ (benchIO, sourceUnfoldr, sourceUnfoldrM, benchIOSrc, drain)
19import System.Random (randomRIO)
20import System.Random (randomRIO)
20#ifdef USE_PRELUDE
21#ifdef USE_PRELUDE
21−import Streamly.Benchmark.Prelude hiding
22− (sourceUnfoldr, sourceUnfoldrM, benchIOSrc)
23import qualified Streamly.Internal.Data.Stream.IsStream as Stream
22import qualified Streamly.Internal.Data.Stream.IsStream as Stream
24#else
23#else
25−import Streamly.Benchmark.Prelude (benchIO)
26import qualified Streamly.Internal.Data.Stream as Stream
24import qualified Streamly.Internal.Data.Stream as Stream
27#endif
25#endif
28import qualified Streamly.Internal.Data.Fold as Fold
26import qualified Streamly.Internal.Data.Fold as Fold
benchmark/Streamly/Benchmark/Data/Stream/Reduce.hs+2−3
@@ -17,7 +17,6 @@ import Control.DeepSeq (NFData(..))
17import Control.Monad.IO.Class (MonadIO(..))
17import Control.Monad.IO.Class (MonadIO(..))
18import Data.Monoid (Sum(..))
18import Data.Monoid (Sum(..))
19import GHC.Generics (Generic)
19import GHC.Generics (Generic)
20−import Streamly.Internal.Data.IsMap.HashMap ()
21import Streamly.Internal.Data.Stream (Stream)
20import Streamly.Internal.Data.Stream (Stream)
22
21
23import qualified Streamly.Internal.Data.Refold.Type as Refold
22import qualified Streamly.Internal.Data.Refold.Type as Refold
@@ -27,15 +26,15 @@ import qualified Stream.Common as Common
27import Control.Monad (when)
26import Control.Monad (when)
28import Data.Proxy (Proxy(..))
27import Data.Proxy (Proxy(..))
29import Data.HashMap.Strict (HashMap)
28import Data.HashMap.Strict (HashMap)
29+import Streamly.Internal.Data.IsMap.HashMap ()
30import qualified Streamly.Internal.Data.Stream.IsStream as S
30import qualified Streamly.Internal.Data.Stream.IsStream as S
31import Streamly.Prelude (fromSerial)
31import Streamly.Prelude (fromSerial)
32import Streamly.Benchmark.Prelude hiding
32import Streamly.Benchmark.Prelude hiding
33− ( benchIOSrc, sourceUnfoldrM, apDiscardFst, apDiscardSnd, apLiftA2
33+ ( benchIO, benchIOSrc, sourceUnfoldrM, apDiscardFst, apDiscardSnd, apLiftA2
34 , toNullAp, monadThen, toNullM, toNullM3, filterAllInM, filterAllOutM
34 , toNullAp, monadThen, toNullM, toNullM3, filterAllInM, filterAllOutM
35 , filterSome, breakAfterSome, toListM, toListSome, transformMapM
35 , filterSome, breakAfterSome, toListM, toListSome, transformMapM
36 , transformComposeMapM, transformTeeMapM, transformZipMapM)
36 , transformComposeMapM, transformTeeMapM, transformZipMapM)
37#else
37#else
38−import Streamly.Benchmark.Prelude (benchIO)
39import qualified Streamly.Internal.Data.Stream as S
38import qualified Streamly.Internal.Data.Stream as S
40#endif
39#endif
41
40
benchmark/Streamly/Benchmark/Data/Stream/Transform.hs−2
@@ -32,11 +32,9 @@ import qualified Prelude
32import qualified Stream.Common as Common
32import qualified Stream.Common as Common
33import qualified Streamly.Internal.Data.Unfold as Unfold
33import qualified Streamly.Internal.Data.Unfold as Unfold
34#ifdef USE_PRELUDE
34#ifdef USE_PRELUDE
35−import Streamly.Benchmark.Prelude (benchIO)
36import qualified Streamly.Internal.Data.Stream.IsStream as Stream
35import qualified Streamly.Internal.Data.Stream.IsStream as Stream
37import Streamly.Internal.Data.Time.Units
36import Streamly.Internal.Data.Time.Units
38#else
37#else
39−import Streamly.Benchmark.Prelude (benchIO)
40import qualified Streamly.Internal.Data.Stream as Stream
38import qualified Streamly.Internal.Data.Stream as Stream
41#endif
39#endif
42
40
benchmark/streamly-benchmarks.cabal+3−4
@@ -76,6 +76,9 @@ flag use-prelude
76common compile-options
76common compile-options
77 default-language: Haskell2010
77 default-language: Haskell2010
78
78
79+ if flag(use-streamly-core)
80+ cpp-options: -DUSE_STREAMLY_CORE
81+
79 if flag(use-prelude)
82 if flag(use-prelude)
80 cpp-options: -DUSE_PRELUDE
83 cpp-options: -DUSE_PRELUDE
81
84
@@ -235,10 +238,6 @@ benchmark Data.Stream
235 if flag(use-prelude)
238 if flag(use-prelude)
236 other-modules:
239 other-modules:
237 Stream.Split
240 Stream.Split
238− if flag(use-streamly-core) || impl(ghcjs)
239− buildable: False
240− else
241− buildable: True
242 if flag(limit-build-mem)
241 if flag(limit-build-mem)
243 if flag(dev)
242 if flag(dev)
244 ghc-options: +RTS -M3500M -RTS
243 ghc-options: +RTS -M3500M -RTS