Bryan O'Sullivan avatar Bryan O'Sullivan committed 2f2e49f

Render many sets of hopefully charts.

Comments (0)

Files changed (1)

 
 main = do
   args <- getArgs
-  forM_ args $ \arg -> do
-    d <- groupRows `fmap` readCSV arg
-    forM_ (M.toList d) $ \(tdesc,rows) -> do
-        let desc = T.unpack tdesc
-        --renderableToWindow (renderMark desc rows) 400 160
-        renderableToPNGFile (renderMark desc rows) 400 160
-                            (printf "time-%s.png" (map clean desc))
+  groups <- mapM (fmap groupRows . readCSV) args
+  let dd = M.unionsWith (++) . map (M.map (:[])) $ groups
+  forM_ (M.toList dd) $ \(tdesc,rows) -> do
+      let desc = T.unpack tdesc
+      if False
+       then renderableToWindow (renderMark desc rows) 400 160
+       else renderableToPNGFile (renderMark desc rows) 400 160
+                                (printf "time-%s.png" (map clean desc))
   where clean '/' = '-'
         clean c | isSpace c = '-'
                 | otherwise = c
     barsReference = LogValue 1e-300
     barsAdd (LogValue a) (LogValue b) = LogValue (a * b)
 
-renderMark :: String -> [Row] -> Renderable ()
+renderMark :: String -> [[Row]] -> Renderable ()
 renderMark desc rows
-  | minimum values * 50 >= maximum values = toRenderable linLayout
-  | otherwise                             = toRenderable logLayout
+  | useLog    = toRenderable linLayout
+  | otherwise = toRenderable logLayout
   where
-    values = map rowMean rows
-    keys   = map git rows
+    useLog = minimum (map minimum values) >= maximum (map maximum values) / 25
+    values = transpose . map (map rowMean) $ rows
+    keys   = map git (head rows)
         where git r = let n = T.unpack . rowName $ r
                       in maybe n id . flip lookup mappings $ n
     mappings = [("bl", "lazy BS"), ("bs", "strict BS"), ("l", "list"),
     bottomAxis = laxis_generate ^= autoScaledAxis typeAxis
                $ defaultLayoutAxis
 
-    linBars = plot_bars_values ^= (zip [0.5,1.5..] . map (:[]) $ values)
+    linBars = plot_bars_values ^= (zip [0.5,1.5..] values)
             $ defaultPlotBars
 
-    logBars = plot_bars_values ^= (zip [0.5,1.5..] . map ((:[]) . LogValue) $ values)
+    logBars = plot_bars_values ^= (zip [0.5,1.5..] . map (map LogValue) $ values)
             $ defaultPlotBars
 
     typeAxis = la_labelf ^= (ix keys . floor)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.