on 1f0dc07 help sign in
streamly/benchmark/Nested.hs
81 lines 3.5 kB history raw
1-- |
2-- Module : Main
3-- Copyright : (c) 2018 Harendra Kumar
4--
5-- License : BSD3
6-- Maintainer : harendra.kumar@gmail.com
8import Control.DeepSeq (NFData)
9import Data.Functor.Identity (Identity, runIdentity)
10import System.Random (randomRIO)
11import qualified NestedOps as Ops
12import Streamly
13import Gauge
15benchIO :: (NFData b) => String -> (Int -> IO b) -> Benchmark
16benchIO name f = bench name $ nfIO $ randomRIO (1,1) >>= f
18_benchId :: (NFData b) => String -> (Int -> Identity b) -> Benchmark
19_benchId name f = bench name $ nf (\g -> runIdentity (g 1)) f
21main :: IO ()
22main = do
23 -- TBD Study scaling with 10, 100, 1000 loop iterations
24 defaultMain
25 [ bgroup "linear"
26 [ benchIO "toNullLinear" Ops.toNullLinear
27 , benchIO "toListLinear" Ops.toListLinear
28 ]
30 , bgroup "streamly"
31 [ benchIO "append" $ Ops.append streamly
32 , benchIO "toNull0" $ Ops.toNull0 streamly
33 , benchIO "toList0" $ Ops.toList0 streamly
34 , benchIO "toNull" $ Ops.toNull streamly
35 , benchIO "toList" $ Ops.toList streamly
36 , benchIO "toListSome" $ Ops.toListSome streamly
37 , benchIO "filterAllOut" $ Ops.filterAllOut streamly
38 , benchIO "filterAllIn" $ Ops.filterAllIn streamly
39 , benchIO "filterSome" $ Ops.filterSome streamly
40 , benchIO "breakAfterSome" $ Ops.breakAfterSome streamly
41 ]
43 , bgroup "costreamly"
44 [ benchIO "append" $ Ops.append costreamly
45 , benchIO "toNull0" $ Ops.toNull0 costreamly
46 , benchIO "toList0" $ Ops.toList0 costreamly
47 , benchIO "toNull" $ Ops.toNull costreamly
48 , benchIO "toList" $ Ops.toList costreamly
49 , benchIO "toListSome" $ Ops.toListSome costreamly
50 , benchIO "filterAllOut" $ Ops.filterAllOut costreamly
51 , benchIO "filterAllIn" $ Ops.filterAllIn costreamly
52 , benchIO "filterSome" $ Ops.filterSome costreamly
53 , benchIO "breakAfterSome" $ Ops.breakAfterSome costreamly
54 ]
56 , bgroup "Coparallely"
57 [ benchIO "append" $ Ops.append coparallely
58 , benchIO "toNull0" $ Ops.toNull0 coparallely
59 , benchIO "toList0" $ Ops.toList0 coparallely
60 , benchIO "toNull" $ Ops.toNull coparallely
61 , benchIO "toList" $ Ops.toList coparallely
62 , benchIO "toListSome" $ Ops.toListSome coparallely
63 , benchIO "filterAllOut" $ Ops.filterAllOut coparallely
64 , benchIO "filterAllIn" $ Ops.filterAllIn coparallely
65 , benchIO "filterSome" $ Ops.filterSome coparallely
66 , benchIO "breakAfterSome" $ Ops.breakAfterSome coparallely
67 ]
69 , bgroup "Parallely"
70 [ benchIO "append" $ Ops.append parallely
71 , benchIO "toNull0" $ Ops.toNull0 parallely
72 , benchIO "toList0" $ Ops.toList0 parallely
73 , benchIO "toNull" $ Ops.toNull parallely
74 , benchIO "toList" $ Ops.toList parallely
75 , benchIO "toListSome" $ Ops.toListSome parallely
76 , benchIO "filterAllOut" $ Ops.filterAllOut parallely
77 , benchIO "filterAllIn" $ Ops.filterAllIn parallely
78 , benchIO "filterSome" $ Ops.filterSome parallely
79 , benchIO "breakAfterSome" $ Ops.breakAfterSome parallely
80 ]
81 ]