3-- Copyright : (c) 2018 Composewell Technologies
4-- License : BSD-3-Clause
5-- Maintainer : streamly@composewell.com
8{-# LANGUAGE FlexibleContexts #-}
9{-# LANGUAGE ScopedTypeVariables #-}
10{-# LANGUAGE RankNTypes #-}
14{-# OPTIONS_GHC -ddump-simpl -ddump-to-file -dsuppress-all #-}
17module Main (main) where
19import Streamly.Benchmark.Common.Handle (mkHandleBenchEnv)
21import qualified Stream.Eliminate as Elimination
22#ifndef USE_STREAMLY_CORE
23import qualified Stream.Exceptions as Exceptions
25import qualified Stream.Expand as NestedStream
26import qualified Stream.Generate as Generation
27import qualified Stream.Lift as Lift
28import qualified Stream.Reduce as NestedFold
30import qualified Stream.Split as Split
32import qualified Stream.Transform as Transformation
34import Streamly.Benchmark.Common
37import Data.Function ((&))
38import Streamly.Data.Stream (Stream)
39import qualified Streamly.Internal.Data.Stream as Stream
40import qualified Streamly.Internal.Data.Fold as Fold
41import qualified Data.Foldable as Foldable
47moduleName = "Data.Stream.StreamDK"
49moduleName = "Data.Stream"
52-------------------------------------------------------------------------------
54-------------------------------------------------------------------------------
56-- In addition to gauge options, the number of elements in the stream can be
57-- passed using the --stream-size option.
62 env <- mkHandleBenchEnv
63 runWithCLIOpts defaultStreamSize (allBenchmarks env)
67 allBenchmarks env size = Prelude.concat
68 [ Generation.benchmarks moduleName size
69 , Elimination.benchmarks moduleName size
70#ifndef USE_STREAMLY_CORE
71 , Exceptions.benchmarks moduleName env size
74 , Split.benchmarks moduleName env
76 , Transformation.benchmarks moduleName size
77 , NestedFold.benchmarks moduleName size
78 , Lift.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
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list