@@ -7,8 +7,10 @@ module Main where
7import Control.Exception (handle, catch, SomeException, ErrorCall(..))
7import Control.Exception (handle, catch, SomeException, ErrorCall(..))
8import Control.Monad.Trans.State
8import Control.Monad.Trans.State
9import Control.Monad.Trans.Maybe
9import Control.Monad.Trans.Maybe
10+import Data.Function (on, (&))
10import Data.List
11import Data.List
11import Data.List.Split
12import Data.List.Split
13+import Data.Maybe (mapMaybe)
12import Data.Ord (comparing)
14import Data.Ord (comparing)
13import System.Environment (getArgs)
15import System.Environment (getArgs)
14import Control.Monad.IO.Class (liftIO)
16import Control.Monad.IO.Class (liftIO)
@@ -100,21 +102,21 @@ ignoringErr a = catch a (\(ErrorCall err :: ErrorCall) ->
100------------------------------------------------------------------------------
102------------------------------------------------------------------------------
102makeLinearGraphs :: Config -> String -> IO ()
104makeLinearGraphs :: Config -> String -> IO ()
103−makeLinearGraphs cfg inputFile = do
105+makeLinearGraphs cfg@Config{..} inputFile = do
104 ignoringErr $ graph inputFile "generation" $ cfg
106 ignoringErr $ graph inputFile "generation" $ cfg
105− { title = Just "Generation"
107+ { title = (++) <$> title <*> Just " generation"
106 , classifyBenchmark =
108 , classifyBenchmark =
107 fmap ("Streamly",) . stripPrefix "serially/generation/"
109 fmap ("Streamly",) . stripPrefix "serially/generation/"
110 ignoringErr $ graph inputFile "elimination" $ cfg
112 ignoringErr $ graph inputFile "elimination" $ cfg
111− { title = Just "Elimination"
113+ { title = (++) <$> title <*> Just " Elimination"
112 , classifyBenchmark =
114 , classifyBenchmark =
113 fmap ("Streamly",) . stripPrefix "serially/elimination/"
115 fmap ("Streamly",) . stripPrefix "serially/elimination/"
116 ignoringErr $ graph inputFile "transformation-zip" $ cfg
118 ignoringErr $ graph inputFile "transformation-zip" $ cfg
117− { title = Just "Transformation & Zip"
119+ { title = (++) <$> title <*> Just " Transformation & Zip"
118 , classifyBenchmark = \b ->
120 , classifyBenchmark = \b ->
119 if "serially/transformation/" `isPrefixOf` b
121 if "serially/transformation/" `isPrefixOf` b
120 || "serially/zip" `isPrefixOf` b
122 || "serially/zip" `isPrefixOf` b
@@ -123,34 +125,34 @@ makeLinearGraphs cfg inputFile = do
125 ignoringErr $ graph inputFile "filtering" $ cfg
127 ignoringErr $ graph inputFile "filtering" $ cfg
126− { title = Just "Filtering"
128+ { title = (++) <$> title <*> Just " Filtering"
127 , classifyBenchmark =
129 , classifyBenchmark =
128 fmap ("Streamly",) . stripPrefix "serially/filtering/"
130 fmap ("Streamly",) . stripPrefix "serially/filtering/"
131 ignoringErr $ graph inputFile "transformationX4" $ cfg
133 ignoringErr $ graph inputFile "transformationX4" $ cfg
132− { title = Just "Transformation x 4"
134+ { title = (++) <$> title <*> Just " Transformation x 4"
133 , classifyBenchmark =
135 , classifyBenchmark =
134 fmap ("Streamly",) . stripPrefix "serially/transformationX4/"
136 fmap ("Streamly",) . stripPrefix "serially/transformationX4/"
137 ignoringErr $ graph inputFile "filteringX4"
139 ignoringErr $ graph inputFile "filteringX4"
139− { title = Just "Filtering x 4"
141+ { title = (++) <$> title <*> Just " Filtering x 4"
140 , classifyBenchmark =
142 , classifyBenchmark =
141 fmap ("Streamly",) . stripPrefix "serially/filteringX4/"
143 fmap ("Streamly",) . stripPrefix "serially/filteringX4/"
144 ignoringErr $ graph inputFile "mixedX4"
146 ignoringErr $ graph inputFile "mixedX4"
146− { title = Just "Mixed x 4"
148+ { title = (++) <$> title <*> Just " Mixed x 4"
147 , classifyBenchmark =
149 , classifyBenchmark =
148 fmap ("Streamly",) . stripPrefix "serially/mixedX4/"
150 fmap ("Streamly",) . stripPrefix "serially/mixedX4/"
151 ignoringErr $ graph inputFile "iterated"
153 ignoringErr $ graph inputFile "iterated"
153− { title = Just "Iterate 10 x 100000"
155+ { title = Just "iterate 10,000 times over 10 elems"
154 , classifyBenchmark =
156 , classifyBenchmark =
155 fmap ("Streamly",) . stripPrefix "serially/iterated/"
157 fmap ("Streamly",) . stripPrefix "serially/iterated/"
@@ -161,23 +163,61 @@ makeLinearGraphs cfg inputFile = do
162makeNestedGraphs :: Config -> String -> IO ()
164makeNestedGraphs :: Config -> String -> IO ()
163makeNestedGraphs cfg inputFile =
165makeNestedGraphs cfg inputFile =
164− ignoringErr $ graph inputFile "nested-serial" $ cfg
166+ ignoringErr $ graph inputFile "nested-all" $ cfg
165− { title = Just "Nested serial"
167+ { presentation = Groups Absolute
166− , classifyBenchmark = \b ->
168+ , classifyBenchmark = classifyNested
167− let ls = splitOn "/" b
169+ , selectGroups = \gs ->
168− in case head ls of
170+ groupBy ((==) `on` snd) gs
169− "serially" -> Just (head ls, last ls)
171+ & fmap (\xs -> mapMaybe (\x -> (x,) <$> lookup x xs) order)
170− _ -> Nothing
172+ & concat
177+ order = ["serially", "asyncly", "wAsyncly", "aheadly", "parallely"]
180+ | "serially/" `isPrefixOf` b =
181+ ("serially",) <$> stripPrefix "serially/" b
182+ | "asyncly/" `isPrefixOf` b =
183+ ("asyncly",) <$> stripPrefix "asyncly/" b
184+ | "wAsyncly/" `isPrefixOf` b =
185+ ("wAsyncly",) <$> stripPrefix "wAsyncly/" b
186+ | "aheadly/" `isPrefixOf` b =
187+ ("aheadly",) <$> stripPrefix "aheadly/" b
188+ | "parallely/" `isPrefixOf` b =
189+ ("parallely",) <$> stripPrefix "parallely/" b
190+ | otherwise = Nothing
173------------------------------------------------------------------------------
192------------------------------------------------------------------------------
174-- Charts for parallel streams
193-- Charts for parallel streams
175------------------------------------------------------------------------------
194------------------------------------------------------------------------------
177makeLinearAsyncGraphs :: Config -> String -> IO ()
196makeLinearAsyncGraphs :: Config -> String -> IO ()
178−makeLinearAsyncGraphs cfg inputFile = do
197+makeLinearAsyncGraphs cfg inputFile =
179− putStrLn "Not implemented"
198+ ignoringErr $ graph inputFile "linear-async" cfg
180− return ()
199+ { presentation = Groups Absolute
200+ , classifyBenchmark = classifyAsync
201+ , selectGroups = \gs ->
202+ groupBy ((==) `on` snd) gs
203+ & fmap (\xs -> mapMaybe (\x -> (x,) <$> lookup x xs) order)
209+ order = ["asyncly", "wAsyncly", "aheadly", "parallely"]
212+ | "asyncly/" `isPrefixOf` b =
213+ ("asyncly",) <$> stripPrefix "asyncly/" b
214+ | "wAsyncly/" `isPrefixOf` b =
215+ ("wAsyncly",) <$> stripPrefix "wAsyncly/" b
216+ | "aheadly/" `isPrefixOf` b =
217+ ("aheadly",) <$> stripPrefix "aheadly/" b
218+ | "parallely/" `isPrefixOf` b =
219+ ("parallely",) <$> stripPrefix "parallely/" b
220+ | otherwise = Nothing
182makeLinearRateGraphs :: Config -> String -> IO ()
222makeLinearRateGraphs :: Config -> String -> IO ()
183makeLinearRateGraphs cfg inputFile = do
223makeLinearRateGraphs cfg inputFile = do
@@ -188,18 +228,22 @@ makeLinearRateGraphs cfg inputFile = do
188-- Reports/Charts for base streams
228-- Reports/Charts for base streams
189------------------------------------------------------------------------------
229------------------------------------------------------------------------------
192− | "streamD/" `isPrefixOf` b = ("streamD",) <$> stripPrefix "streamD/" b
193− | "streamK/" `isPrefixOf` b = ("streamK",) <$> stripPrefix "streamK/" b
194− | otherwise = Nothing
196showStreamDVsK Options{..} cfg inp out =
231showStreamDVsK Options{..} cfg inp out =
197 let cfg' = cfg { classifyBenchmark = classifyBase }
232 let cfg' = cfg { classifyBenchmark = classifyBase }
198 in if genGraphs
233 in if genGraphs
199 then ignoringErr $ graph inp "streamD-vs-streamK"
234 then ignoringErr $ graph inp "streamD-vs-streamK"
200− cfg' {outputDir = Just out}
235+ cfg' { outputDir = Just out
236+ , presentation = Groups Absolute
201 else ignoringErr $ report inp Nothing cfg'
238 else ignoringErr $ report inp Nothing cfg'
243+ | "streamD/" `isPrefixOf` b = ("streamD",) <$> stripPrefix "streamD/" b
244+ | "streamK/" `isPrefixOf` b = ("streamK",) <$> stripPrefix "streamK/" b
245+ | otherwise = Nothing
203showStreamD Options{..} cfg inp out =
247showStreamD Options{..} cfg inp out =
204 let cfg' = cfg { classifyBenchmark = classifyStreamD }
248 let cfg' = cfg { classifyBenchmark = classifyStreamD }
205 in if genGraphs
249 in if genGraphs
@@ -258,27 +302,34 @@ main = do
258 return ()
302 return ()
259 Just opts@Options{..} ->
303 Just opts@Options{..} ->
260 case benchType of
304 case benchType of
261− Linear -> benchShow opts cfg makeLinearGraphs
305+ Linear -> benchShow opts cfg
306+ { title = Just "100,000 elems" }
262 "charts/linear/results.csv"
308 "charts/linear/results.csv"
263 "charts/linear"
309 "charts/linear"
264− LinearAsync -> benchShow opts cfg makeLinearAsyncGraphs
310+ LinearAsync -> benchShow opts cfg
311+ { title = Just "Async 10,000 elems" }
312+ makeLinearAsyncGraphs
265 "charts/linear-async/results.csv"
313 "charts/linear-async/results.csv"
266 "charts/linear-async"
314 "charts/linear-async"
267 LinearRate -> benchShow opts cfg makeLinearRateGraphs
315 LinearRate -> benchShow opts cfg makeLinearRateGraphs
268 "charts/linear-rate/results.csv"
316 "charts/linear-rate/results.csv"
269 "charts/linear-rate"
317 "charts/linear-rate"
270− Nested -> benchShow opts cfg makeNestedGraphs
318+ Nested -> benchShow opts cfg
319+ { title = Just "Nested loops 100 x 100 elems" }
271 "charts/nested/results.csv"
321 "charts/nested/results.csv"
272 "charts/nested"
322 "charts/nested"
273− Base ->
323+ Base -> do
324+ let cfg' = cfg { title = Just "100,000 elems" }
274 if groupDiff
325 if groupDiff
275− then showStreamDVsK opts cfg
326+ then showStreamDVsK opts cfg'
276 "charts/base/results.csv"
327 "charts/base/results.csv"
277 "charts/base"
328 "charts/base"
279− showStreamD opts cfg
330+ showStreamD opts cfg'
280 "charts/base/results.csv"
331 "charts/base/results.csv"
281 "charts/base"
332 "charts/base"
282− showStreamK opts cfg
333+ showStreamK opts cfg'
283 "charts/base/results.csv"
334 "charts/base/results.csv"
284 "charts/base"
335 "charts/base"