on master help sign in
Render many sets of hopefully charts.
265c871Bryan O'Sullivan
tests/Chartem.hs+16−14
@@ -51,13 +51,14 @@ groupRows = M.map (sortBy (compare `on` rowName)) . foldr f M.empty
51
51
52main = do
52main = do
53 args <- getArgs
53 args <- getArgs
54− forM_ args $ \arg -> do
54+ groups <- mapM (fmap groupRows . readCSV) args
55− d <- groupRows `fmap` readCSV arg
55+ let dd = M.unionsWith (++) . map (M.map (:[])) $ groups
56− forM_ (M.toList d) $ \(tdesc,rows) -> do
56+ forM_ (M.toList dd) $ \(tdesc,rows) -> do
57− let desc = T.unpack tdesc
57+ let desc = T.unpack tdesc
58+ if False
58− --renderableToWindow (renderMark desc rows) 400 160
59+ then renderableToWindow (renderMark desc rows) 400 160
59− renderableToPNGFile (renderMark desc rows) 400 160
60+ else renderableToPNGFile (renderMark desc rows) 400 160
60− (printf "time-%s.png" (map clean desc))
61+ (printf "time-%s.png" (map clean desc))
61 where clean '/' = '-'
62 where clean '/' = '-'
62 clean c | isSpace c = '-'
63 clean c | isSpace c = '-'
63 | otherwise = c
64 | otherwise = c
@@ -66,13 +67,14 @@ instance BarsPlotValue LogValue where
66 barsReference = LogValue 1e-300
67 barsReference = LogValue 1e-300
67 barsAdd (LogValue a) (LogValue b) = LogValue (a * b)
68 barsAdd (LogValue a) (LogValue b) = LogValue (a * b)
68
69
69−renderMark :: String -> [Row] -> Renderable ()
70+renderMark :: String -> [[Row]] -> Renderable ()
70renderMark desc rows
71renderMark desc rows
71− | minimum values * 50 >= maximum values = toRenderable linLayout
72+ | useLog = toRenderable linLayout
72− | otherwise = toRenderable logLayout
73+ | otherwise = toRenderable logLayout
73 where
74 where
75+ useLog = minimum (map minimum values) >= maximum (map maximum values) / 25
74− values = map rowMean rows
76+ values = transpose . map (map rowMean) $ rows
75− keys = map git rows
77+ keys = map git (head rows)
76 where git r = let n = T.unpack . rowName $ r
78 where git r = let n = T.unpack . rowName $ r
77 in maybe n id . flip lookup mappings $ n
79 in maybe n id . flip lookup mappings $ n
78 mappings = [("bl", "lazy BS"), ("bs", "strict BS"), ("l", "list"),
80 mappings = [("bl", "lazy BS"), ("bs", "strict BS"), ("l", "list"),
@@ -101,10 +103,10 @@ renderMark desc rows
101 bottomAxis = laxis_generate ^= autoScaledAxis typeAxis
103 bottomAxis = laxis_generate ^= autoScaledAxis typeAxis
102 $ defaultLayoutAxis
104 $ defaultLayoutAxis
103
105
104− linBars = plot_bars_values ^= (zip [0.5,1.5..] . map (:[]) $ values)
106+ linBars = plot_bars_values ^= (zip [0.5,1.5..] values)
105 $ defaultPlotBars
107 $ defaultPlotBars
106
108
107− logBars = plot_bars_values ^= (zip [0.5,1.5..] . map ((:[]) . LogValue) $ values)
109+ logBars = plot_bars_values ^= (zip [0.5,1.5..] . map (map LogValue) $ values)
108 $ defaultPlotBars
110 $ defaultPlotBars
109
111
110 typeAxis = la_labelf ^= (ix keys . floor)
112 typeAxis = la_labelf ^= (ix keys . floor)