3#include "Streamly/Benchmark/Data/Array/CommonImports.hs"
5import Control.DeepSeq (deepseq)
7import qualified Streamly.Internal.Data.SmallArray as A
8type Stream = A.SmallArray
10#include "Streamly/Benchmark/Data/Array/Common.hs"
12-------------------------------------------------------------------------------
14-------------------------------------------------------------------------------
16-- Drain a source that generates an array in the IO monad
17{-# INLINE benchIOSrc #-}
18benchIOSrc :: NFData a => String -> (Int -> IO (Stream a)) -> Benchmark
19benchIOSrc name src = benchIO name src id
21-------------------------------------------------------------------------------
23-------------------------------------------------------------------------------
25{-# INLINE sourceIntFromToFromList #-}
26sourceIntFromToFromList :: MonadIO m => Int -> Int -> m (Stream Int)
27sourceIntFromToFromList value n = P.return $ A.fromListN value [n..n + value]
29{-# INLINE readInstance #-}
30readInstance :: P.String -> Stream Int
35 _ -> P.error "readInstance: no parse"
39{-# INLINE foldableFoldl' #-}
40foldableFoldl' :: Stream Int -> Int
41foldableFoldl' = F.foldl' (+) 0
43{-# INLINE foldableSum #-}
44foldableSum :: Stream Int -> Int
49-------------------------------------------------------------------------------
51-------------------------------------------------------------------------------
53o_1_space_generation :: Int -> [Benchmark]
54o_1_space_generation value =
60 "[1" ++ concat (replicate value ",1") ++ "]"
61 in testStr `deepseq` bench "read" (nf readInstance testStr)
66o_1_space_elimination :: Int -> [Benchmark]
67o_1_space_elimination value =
68 [ bgroup "elimination"
72 benchPureSink value "foldable/foldl'" foldableFoldl'
73 , benchPureSink value "foldable/sum" foldableSum
81moduleName = "Data.SmallArray"
87main = runWithCLIOpts defStreamSize allBenchmarks
92 bgroup (o_1_space_prefix moduleName) (o_1_space_generation size)
93 : commonBenchmarks size
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