+-- A summary table, useful only when we are comparing two runs. This table
+-- shows a number of different result categories, one per column.
+ascii_summary_table
+ :: Bool -- generate a LaTeX table?
+ -> [ResultTable]
+ -> [PerProgTableSpec]
+ -> ShowS
+ascii_summary_table latex (r1:r2:_) specs
+ | latex = makeLatexTable (rows ++ TableLine : av_rows)
+ | otherwise =
+ makeTable (table_layout (length specs) width)
+ (TableLine : TableRow header : TableLine : rows ++ TableLine : av_rows)
+ where
+ header = BoxString "Program" : map BoxString headings
+
+ (headings, columns, av_cols) = unzip3 (map calc_col specs)
+ av_heads = [BoxString "Min", BoxString "Max", BoxString "Geometric Mean"]
+ baseline = fmToList r1
+ progs = map BoxString (keysFM r1)
+ rows' = map TableRow (zipWith (:) progs (transpose columns))
+
+ rows | latex = mungeForLaTeX rows'
+ | otherwise = rows'
+
+ av_rows = map TableRow (zipWith (:) av_heads (transpose av_cols))
+ width = 10
+
+ calc_col (SpecP _ heading _ getr gets ok)
+ = (heading, column, [min,max,mean]) -- throw away the baseline result
+ where (_, boxes) = unzip (map calc_one_result baseline)
+ calc_one_result = calc_result [r2] getr gets ok
+ column = map (\(_:b:_) -> b) boxes
+ (_,mean,_) = calc_gmsd column
+ (min,max) = calc_minmax column
+
+mungeForLaTeX :: [TableRow] -> [TableRow]
+mungeForLaTeX = filter keep_it
+ where keep_it (TableRow (BoxString s: _)) = ok s
+ keep_it TableLine = True
+ keep_it _ = False
+
+ ok s = s `elem` progs_to_keep
+
+progs_to_keep = [
+ "anna", "cacheprof", "circsim", "compress",
+ "fem", "fulsom", "fibheaps", "hidden",
+ "infer", "typecheck", "scs", "simple"
+ ]
+
+table_layout n width =
+ (str . rjustify 15) :
+ (\s -> str (space 5) . str (rjustify width s)) :
+ replicate (n-1) (str . rjustify width)
+