1{-# OPTIONS_GHC -Wno-deprecations #-}
5#include "Streamly/Benchmark/Data/Array/CommonImports.hs"
7import Control.DeepSeq (deepseq)
9import qualified Streamly.Internal.Data.SmallArray as A
10type Stream = A.SmallArray
12#include "Streamly/Benchmark/Data/Array/Common.hs"
14-------------------------------------------------------------------------------
16-------------------------------------------------------------------------------
18-- Drain a source that generates an array in the IO monad
19{-# INLINE benchIOSrc #-}
20benchIOSrc :: NFData a => String -> (Int -> IO (Stream a)) -> Benchmark
21benchIOSrc name src = benchIO name src id
23-------------------------------------------------------------------------------
25-------------------------------------------------------------------------------
27{-# INLINE sourceIntFromToFromList #-}
28sourceIntFromToFromList :: MonadIO m => Int -> Int -> m (Stream Int)
29sourceIntFromToFromList value n = P.return $ A.fromListN value [n..n + value]
31{-# INLINE readInstance #-}
32readInstance :: P.String -> Stream Int
37 _ -> P.error "readInstance: no parse"
41{-# INLINE foldableFoldl' #-}
42foldableFoldl' :: Stream Int -> Int
43foldableFoldl' = F.foldl' (+) 0
45{-# INLINE foldableSum #-}
46foldableSum :: Stream Int -> Int
51-------------------------------------------------------------------------------
53-------------------------------------------------------------------------------
55o_1_space_generation :: Int -> [Benchmark]
56o_1_space_generation value =
62 "[1" ++ concat (replicate value ",1") ++ "]"
63 in testStr `deepseq` bench "read" (nf readInstance testStr)
68o_1_space_elimination :: Int -> [Benchmark]
69o_1_space_elimination value =
70 [ bgroup "elimination"
74 benchPureSink value "foldable/foldl'" foldableFoldl'
75 , benchPureSink value "foldable/sum" foldableSum
83moduleName = "Data.SmallArray"
89main = runWithCLIOpts defStreamSize allBenchmarks
94 bgroup (o_1_space_prefix moduleName) (o_1_space_generation size)
95 : 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