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)
43 [ -- benchIO "unfoldr" $ Ops.toNull asyncly
44 benchSrcIO asyncly "unfoldrM" Ops.sourceUnfoldrM
45 -- , benchSrcIO asyncly "fromFoldable" Ops.sourceFromFoldable
46 , benchSrcIO asyncly "fromFoldableM" Ops.sourceFromFoldableM
47 -- , benchSrcIO asyncly "foldMapWith" Ops.sourceFoldMapWith
48 , benchSrcIO asyncly "foldMapWithM" Ops.sourceFoldMapWithM
49 , benchIO "mapM" $ Ops.mapM asyncly 1
50 , benchSrcIO asyncly "unfoldrM maxThreads 1"
51 (maxThreads 1 . Ops.sourceUnfoldrM)
52 , benchSrcIO asyncly "unfoldrM maxBuffer 1 (1000 ops)"
53 (maxBuffer 1 . Ops.sourceUnfoldrMN 1000)
56 [ -- benchIO "unfoldr" $ Ops.toNull wAsyncly
57 benchSrcIO wAsyncly "unfoldrM" Ops.sourceUnfoldrM
58 -- , benchSrcIO wAsyncly "fromFoldable" Ops.sourceFromFoldable
59 , benchSrcIO wAsyncly "fromFoldableM" Ops.sourceFromFoldableM
60 -- , benchSrcIO wAsyncly "foldMapWith" Ops.sourceFoldMapWith
61 , benchSrcIO wAsyncly "foldMapWithM" Ops.sourceFoldMapWithM
62 , benchIO "mapM" $ Ops.mapM wAsyncly 1
64 -- unfoldr and fromFoldable are always serial and thereofore the same for
67 [ -- benchIO "unfoldr" $ Ops.toNull aheadly
68 benchSrcIO aheadly "unfoldrM" Ops.sourceUnfoldrM
69 , benchSrcIO aheadly "fromFoldableM" Ops.sourceFromFoldableM
70 -- , benchSrcIO aheadly "foldMapWith" Ops.sourceFoldMapWith
71 , benchSrcIO aheadly "foldMapWithM" Ops.sourceFoldMapWithM
72 , benchIO "mapM" $ Ops.mapM aheadly 1
73 , benchSrcIO aheadly "unfoldrM maxThreads 1"
74 (maxThreads 1 . Ops.sourceUnfoldrM)
75 , benchSrcIO aheadly "unfoldrM maxBuffer 1 (1000 ops)"
76 (maxBuffer 1 . Ops.sourceUnfoldrMN 1000)
77 -- , benchSrcIO aheadly "fromFoldable" Ops.sourceFromFoldable
79 -- XXX need to use smaller streams to finish in reasonable time
81 [ --benchIO "unfoldr" $ Ops.toNull parallely
82 benchSrcIO parallely "unfoldrM" Ops.sourceUnfoldrM
83 --, benchSrcIO parallely "fromFoldable" Ops.sourceFromFoldable
84 , benchSrcIO parallely "fromFoldableM" Ops.sourceFromFoldableM
85 -- , benchSrcIO parallely "foldMapWith" Ops.sourceFoldMapWith
86 , benchSrcIO parallely "foldMapWithM" Ops.sourceFoldMapWithM
87 , benchIO "mapM" $ Ops.mapM parallely 1
88 -- Zip has only one parallel flavor
89 , benchIO "zip" Ops.zipAsync
90 , benchIO "zipM" Ops.zipAsyncM
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