@@ -9,6 +9,11 @@
9{-# LANGUAGE ScopedTypeVariables #-}
9{-# LANGUAGE ScopedTypeVariables #-}
10{-# LANGUAGE RankNTypes #-}
10{-# LANGUAGE RankNTypes #-}
14+{-# OPTIONS_GHC -ddump-simpl -ddump-to-file -dsuppress-all #-}
12module Main (main) where
17module Main (main) where
14import Streamly.Benchmark.Common.Handle (mkHandleBenchEnv)
19import Streamly.Benchmark.Common.Handle (mkHandleBenchEnv)
@@ -28,6 +33,15 @@ import qualified Stream.Transform as Transformation
29import Streamly.Benchmark.Common
34import Streamly.Benchmark.Common
37+import Data.Function ((&))
38+import Streamly.Data.Stream (Stream)
39+import qualified Streamly.Internal.Data.Stream.StreamD as Stream
40+import qualified Streamly.Internal.Data.Fold as Fold
41+import qualified Data.Foldable as Foldable
31moduleName :: String
45moduleName :: String
32#ifdef USE_STREAMK
46#ifdef USE_STREAMK
33moduleName = "Data.Stream.StreamDK"
47moduleName = "Data.Stream.StreamDK"
@@ -44,6 +58,7 @@ moduleName = "Data.Stream"
45main :: IO ()
59main :: IO ()
47 env <- mkHandleBenchEnv
62 env <- mkHandleBenchEnv
48 runWithCLIOpts defaultStreamSize (allBenchmarks env)
63 runWithCLIOpts defaultStreamSize (allBenchmarks env)
@@ -63,3 +78,37 @@ main = do
63 , Lift.benchmarks moduleName size
78 , Lift.benchmarks moduleName size
64 , NestedStream.benchmarks moduleName size
79 , NestedStream.benchmarks moduleName size
82+ -- Enable FUSION_CHECK macro at the beginning of the file
83+ -- Enable one benchmark below, and run the benchmark
84+ -- Check the .dump-simpl output
86+ let input = sourceUnfoldrM value 1
88+ -- Stream.foldr (:) [] input >>= print . Prelude.length
89+ -- Stream.fold (Fold.foldr' (:) []) input >>= print . Prelude.length
91+ -- Stream.toList input >>= print . Prelude.length
92+ -- Stream.fold Fold.toList input >>= print . Prelude.length
94+ -- We can automatically assert that these generate identical core
96+ -- Stream.drain input >>= print
97+ -- Stream.fold Fold.drain input >>= print
99+ -- Stream.last input >>= print
100+ -- Stream.fold Fold.latest input >>= print
102+ -- Stream.length input >>= print
103+ -- Stream.fold Fold.length input >>= print
105+ -- Stream.maximum input >>= print
106+ -- Stream.fold Fold.maximum input >>= print
108+ -- Stream.head input >>= print
109+ -- Stream.fold Fold.one input >>= print
111+ -- composeN 4 (Stream.scanl' (+) 0) input
112+ composeN 4 (Stream.scan (Fold.foldl' (+) 0)) input