3-- Copyright : (c) 2018 Harendra Kumar
6-- Maintainer : harendra.kumar@gmail.com
8import Control.DeepSeq (NFData)
9import Data.Functor.Identity (Identity, runIdentity)
10import System.Random (randomRIO)
11import qualified LinearOps as Ops
16-- We need a monadic bind here to make sure that the function f does not get
17-- completely optimized out by the compiler in some cases.
18benchIO :: NFData b => String -> (Ops.Stream m Int -> IO b) -> Benchmark
19benchIO name f = bench name $ nfIO $ randomRIO (1,1000) >>= f . Ops.source
21benchSrcIO :: String -> (Int -> Ops.Stream IO Int) -> Benchmark
22benchSrcIO name f = bench name $ nfIO $ randomRIO (1,1000) >>= Ops.toNull . f
24benchIOAppend :: (NFData b) => String -> (Int -> IO b) -> Benchmark
25benchIOAppend name f = bench name $ nfIO $ randomRIO (1,1000) >>= f
27_benchId :: NFData b => String -> (Ops.Stream m Int -> Identity b) -> Benchmark
28_benchId name f = bench name $ nf (runIdentity . f) (Ops.source 10)
33 [ bgroup "elimination"
34 [ benchIO "toNull" Ops.toNull
35 , benchSrcIO "fromFoldable" Ops.sourceFromFoldable
36 , benchSrcIO "fromFoldableM" Ops.sourceFromFoldableM
37 , benchSrcIO "foldMapWith" Ops.sourceFoldMapWith
38 , benchSrcIO "unfoldrM" Ops.sourceUnfoldrM
39 , benchIO "toList" Ops.toList
40 , benchIO "fold" Ops.foldl
41 , benchIO "last" Ops.last
43 , bgroup "transformation"
44 [ benchIO "scan" Ops.scan
45 , benchIO "map" Ops.map
46 , benchIO "mapM" Ops.mapM
47 , benchIO "concat" Ops.concat
50 [ benchIO "filter-even" Ops.filterEven
51 , benchIO "filter-all-out" Ops.filterAllOut
52 , benchIO "filter-all-in" Ops.filterAllIn
53 , benchIO "take-all" Ops.takeAll
54 , benchIO "takeWhile-true" Ops.takeWhileTrue
55 , benchIO "drop-all" Ops.dropAll
56 , benchIO "dropWhile-true" Ops.dropWhileTrue
58 , benchIO "zip" Ops.zip
60 [ benchIOAppend "serially" $ Ops.append serially
61 , benchIOAppend "wSerially" $ Ops.append wSerially
62 , benchIOAppend "aheadly" $ Ops.append aheadly
63 , benchIOAppend "asyncly" $ Ops.append asyncly
64 , benchIOAppend "wAsyncly" $ Ops.append wAsyncly
65 , benchIOAppend "parallely" $ Ops.append parallely
68 [ benchIO "mapM" Ops.composeMapM
69 , benchIO "map-with-all-in-filter" Ops.composeMapAllInFilter
70 , benchIO "all-in-filters" Ops.composeAllInFilters
71 , benchIO "all-out-filters" Ops.composeAllOutFilters
73 , bgroup "compose-scaling"
74 -- Scaling with same operation in sequence
75 [ benchIO "1" $ Ops.composeScaling 1
76 , benchIO "2" $ Ops.composeScaling 2
77 , benchIO "3" $ Ops.composeScaling 3
78 , benchIO "4" $ Ops.composeScaling 4
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