3-- Copyright : (c) 2018 Harendra Kumar
6-- Maintainer : harendra.kumar@gmail.com
8import Control.DeepSeq (NFData)
9-- import 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.
19-- | Takes a fold method, and uses it with a default source.
21benchIO :: (IsStream t, NFData b) => String -> (t IO Int -> IO b) -> Benchmark
22benchIO name f = bench name $ nfIO $ randomRIO (1,1) >>= f . Ops.source
24-- | Takes a source, and uses it with a default drain/fold method.
25{-# INLINE benchSrcIO #-}
27 :: (t IO Int -> SerialT IO Int)
32 = bench name $ nfIO $ randomRIO (1,1) >>= Ops.toNull t . f
35_benchId :: NFData b => String -> (Ops.Stream m Int -> Identity b) -> Benchmark
36_benchId name f = bench name $ nf (runIdentity . f) (Ops.source 10)
44 [ -- Most basic, barely stream continuations running
45 benchSrcIO serially "unfoldr" Ops.sourceUnfoldr
46 , benchSrcIO serially "unfoldrM" Ops.sourceUnfoldrM
47 , benchSrcIO serially "fromList" Ops.sourceFromList
48 , benchSrcIO serially "fromListM" Ops.sourceFromListM
49 -- These are essentially cons and consM
50 , benchSrcIO serially "fromFoldable" Ops.sourceFromFoldable
51 , benchSrcIO serially "fromFoldableM" Ops.sourceFromFoldableM
52 -- These are essentially appends
53 , benchSrcIO serially "foldMapWith" Ops.sourceFoldMapWith
54 , benchSrcIO serially "foldMapWithM" Ops.sourceFoldMapWithM
56 , bgroup "elimination"
57 [ benchIO "toNull" $ Ops.toNull serially
58 , benchIO "uncons" Ops.uncons
59 , benchIO "init" Ops.init
60 , benchIO "tail" Ops.tail
61 , benchIO "nullHeadTail" Ops.nullHeadTail
62 , benchIO "mapM_" Ops.mapM_
63 , benchIO "toList" Ops.toList
64 , benchIO "foldr" Ops.foldr
65 , benchIO "foldr1" Ops.foldr1
66 , benchIO "foldrM" Ops.foldrM
67 , benchIO "foldl'" Ops.foldl'
68 , benchIO "foldl1'" Ops.foldl1'
70 , benchIO "last" Ops.last
71 , benchIO "length" Ops.length
72 , benchIO "elem" Ops.elem
73 , benchIO "notElem" Ops.notElem
74 , benchIO "all" Ops.all
75 , benchIO "any" Ops.any
76 , benchIO "and" Ops.and
78 , benchIO "find" Ops.find
79 , benchIO "findIndex" Ops.findIndex
80 , benchIO "elemIndex" Ops.elemIndex
81 , benchIO "maximum" Ops.maximum
82 , benchIO "minimum" Ops.minimum
83 , benchIO "sum" Ops.sum
84 , benchIO "product" Ops.product
86 , bgroup "transformation"
87 [ benchIO "scan" Ops.scan
88 , benchIO "map" Ops.map
89 , benchIO "fmap" Ops.fmap
90 , benchIO "mapM" (Ops.mapM serially)
91 , benchIO "mapMaybe" Ops.mapMaybe
92 , benchIO "mapMaybeM" Ops.mapMaybeM
93 , bench "sequence" $ nfIO $ randomRIO (1,1000) >>= \n ->
94 Ops.sequence serially (Ops.sourceUnfoldrMAction n)
95 , benchIO "findIndices" Ops.findIndices
96 , benchIO "elemIndices" Ops.elemIndices
97 -- , benchIO "concat" Ops.concat
100 [ benchIO "filter-even" Ops.filterEven
101 , benchIO "filter-all-out" Ops.filterAllOut
102 , benchIO "filter-all-in" Ops.filterAllIn
103 , benchIO "take-all" Ops.takeAll
104 , benchIO "takeWhile-true" Ops.takeWhileTrue
105 , benchIO "takeWhileM-true" Ops.takeWhileMTrue
106 , benchIO "drop-all" Ops.dropAll
107 , benchIO "dropWhile-true" Ops.dropWhileTrue
108 , benchIO "dropWhileM-true" Ops.dropWhileMTrue
110 , benchIO "zip" Ops.zip
111 , benchIO "zipM" Ops.zipM
113 [ benchIO "mapM" Ops.composeMapM
114 , benchIO "map-with-all-in-filter" Ops.composeMapAllInFilter
115 , benchIO "all-in-filters" Ops.composeAllInFilters
116 , benchIO "all-out-filters" Ops.composeAllOutFilters
118 -- Scaling with same operation in sequence
119 , bgroup "compose-scaling"
120 [ benchIO "1" $ Ops.composeScaling 1
121 , benchIO "2" $ Ops.composeScaling 2
122 , benchIO "3" $ Ops.composeScaling 3
123 , 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