@@ -11,6 +11,8 @@ import System.Random (randomRIO)
1111import qualified NestedOps as Ops
1212import Streamly
1313import Gauge
14+import System.Environment (getArgs)
15+import Text.Read (readMaybe)
1416
1517benchIO :: (NFData b) => String -> (Int -> IO b) -> Benchmark
1618benchIO name f = bench name $ nfIO $ randomRIO (1,1) >>= f
@@ -19,59 +21,70 @@ _benchId :: (NFData b) => String -> (Int -> Identity b) -> Benchmark
1921_benchId name f = bench name $ nf (\g -> runIdentity (g 1)) f
2022
2123main :: IO ()
22−main =
24+main = do
2325 -- TBD Study scaling with 10, 100, 1000 loop iterations
24− defaultMain
26+ -- Basement.Terminal.initialize required?
27+ args <- getArgs
28+ let (linearCount, args') = parseValue args
29+ (cfg, extra) = parseWith defaultConfig args'
30+ runMode (mode cfg) cfg extra
2531 [
2632 bgroup "aheadly"
27− [ benchIO "toNullAp" $ Ops.toNullAp aheadly
28− , benchIO "toNull" $ Ops.toNull aheadly
29− , benchIO "toNull3" $ Ops.toNull3 aheadly
30− , benchIO "toList" $ Ops.toList aheadly
33+ [ benchIO "toNullAp" $ Ops.toNullAp linearCount aheadly
34+ , benchIO "toNull" $ Ops.toNull linearCount aheadly
35+ , benchIO "toNull3" $ Ops.toNull3 linearCount aheadly
36+ , benchIO "toList" $ Ops.toList linearCount aheadly
3137 -- , benchIO "toListSome" $ Ops.toListSome aheadly
32− , benchIO "filterAllOut" $ Ops.filterAllOut aheadly
33− , benchIO "filterAllIn" $ Ops.filterAllIn aheadly
34− , benchIO "filterSome" $ Ops.filterSome aheadly
35− , benchIO "breakAfterSome" $ Ops.breakAfterSome aheadly
38+ , benchIO "filterAllOut" $ Ops.filterAllOut linearCount aheadly
39+ , benchIO "filterAllIn" $ Ops.filterAllIn linearCount aheadly
40+ , benchIO "filterSome" $ Ops.filterSome linearCount aheadly
41+ , benchIO "breakAfterSome" $ Ops.breakAfterSome linearCount aheadly
3642 ]
3743
3844 , bgroup "asyncly"
39− [ benchIO "toNullAp" $ Ops.toNullAp asyncly
40− , benchIO "toNull" $ Ops.toNull asyncly
41− , benchIO "toNull3" $ Ops.toNull3 asyncly
42− , benchIO "toList" $ Ops.toList asyncly
45+ [ benchIO "toNullAp" $ Ops.toNullAp linearCount asyncly
46+ , benchIO "toNull" $ Ops.toNull linearCount asyncly
47+ , benchIO "toNull3" $ Ops.toNull3 linearCount asyncly
48+ , benchIO "toList" $ Ops.toList linearCount asyncly
4349 -- , benchIO "toListSome" $ Ops.toListSome asyncly
44− , benchIO "filterAllOut" $ Ops.filterAllOut asyncly
45− , benchIO "filterAllIn" $ Ops.filterAllIn asyncly
46− , benchIO "filterSome" $ Ops.filterSome asyncly
47− , benchIO "breakAfterSome" $ Ops.breakAfterSome asyncly
50+ , benchIO "filterAllOut" $ Ops.filterAllOut linearCount asyncly
51+ , benchIO "filterAllIn" $ Ops.filterAllIn linearCount asyncly
52+ , benchIO "filterSome" $ Ops.filterSome linearCount asyncly
53+ , benchIO "breakAfterSome" $ Ops.breakAfterSome linearCount asyncly
4854 ]
4955
5056 , bgroup "wAsyncly"
51− [ benchIO "toNullAp" $ Ops.toNullAp wAsyncly
52− , benchIO "toNull" $ Ops.toNull wAsyncly
53− , benchIO "toNull3" $ Ops.toNull3 wAsyncly
54− , benchIO "toList" $ Ops.toList wAsyncly
57+ [ benchIO "toNullAp" $ Ops.toNullAp linearCount wAsyncly
58+ , benchIO "toNull" $ Ops.toNull linearCount wAsyncly
59+ , benchIO "toNull3" $ Ops.toNull3 linearCount wAsyncly
60+ , benchIO "toList" $ Ops.toList linearCount wAsyncly
5561 -- , benchIO "toListSome" $ Ops.toListSome wAsyncly
56− , benchIO "filterAllOut" $ Ops.filterAllOut wAsyncly
57− , benchIO "filterAllIn" $ Ops.filterAllIn wAsyncly
58− , benchIO "filterSome" $ Ops.filterSome wAsyncly
59− , benchIO "breakAfterSome" $ Ops.breakAfterSome wAsyncly
62+ , benchIO "filterAllOut" $ Ops.filterAllOut linearCount wAsyncly
63+ , benchIO "filterAllIn" $ Ops.filterAllIn linearCount wAsyncly
64+ , benchIO "filterSome" $ Ops.filterSome linearCount wAsyncly
65+ , benchIO "breakAfterSome" $ Ops.breakAfterSome linearCount wAsyncly
6066 ]
6167
6268 , bgroup "parallely"
63− [ benchIO "toNullAp" $ Ops.toNullAp parallely
64− , benchIO "toNull" $ Ops.toNull parallely
65− , benchIO "toNull3" $ Ops.toNull3 parallely
66− , benchIO "toList" $ Ops.toList parallely
69+ [ benchIO "toNullAp" $ Ops.toNullAp linearCount parallely
70+ , benchIO "toNull" $ Ops.toNull linearCount parallely
71+ , benchIO "toNull3" $ Ops.toNull3 linearCount parallely
72+ , benchIO "toList" $ Ops.toList linearCount parallely
6773 --, benchIO "toListSome" $ Ops.toListSome parallely
68− , benchIO "filterAllOut" $ Ops.filterAllOut parallely
69− , benchIO "filterAllIn" $ Ops.filterAllIn parallely
70− , benchIO "filterSome" $ Ops.filterSome parallely
71− , benchIO "breakAfterSome" $ Ops.breakAfterSome parallely
74+ , benchIO "filterAllOut" $ Ops.filterAllOut linearCount parallely
75+ , benchIO "filterAllIn" $ Ops.filterAllIn linearCount parallely
76+ , benchIO "filterSome" $ Ops.filterSome linearCount parallely
77+ , benchIO "breakAfterSome" $ Ops.breakAfterSome linearCount parallely
7278 ]
7379
7480 , bgroup "zipAsyncly"
75− [ benchIO "toNullAp" $ Ops.toNullAp zipAsyncly
81+ [ benchIO "toNullAp" $ Ops.toNullAp linearCount zipAsyncly
7682 ]
7783 ]
84+ where
85+ defaultValue = 100000
86+ parseValue [] = (defaultValue, [])
87+ parseValue a@(x:xs) =
88+ case (readMaybe x :: Maybe Int) of
89+ Just value -> (value, xs)
90+ Nothing -> (defaultValue, a)