[pypy-svn] r59860 - pypy/build/benchmem

hpk at codespeak.net hpk at codespeak.net
Tue Nov 11 08:06:26 CET 2008


Author: hpk
Date: Tue Nov 11 08:06:25 2008
New Revision: 59860

Modified:
   pypy/build/benchmem/report.py
Log:
add support for printing an ReST table 
and use it for the objsize report table.


Modified: pypy/build/benchmem/report.py
==============================================================================
--- pypy/build/benchmem/report.py	(original)
+++ pypy/build/benchmem/report.py	Tue Nov 11 08:06:25 2008
@@ -19,7 +19,7 @@
 parser.add_option("-s", "--show", action="store_true", dest="show",
                   help="show pictures")
 
-def asciitable(table):
+def getmax(table):
     colmax = []
     for row in table:
         if not colmax:
@@ -28,6 +28,10 @@
             colmax = [max(len(str(x)),y) for x,y in
                       zip(row + [0] * (len(colmax) - len(row)),
                           colmax + [0] * (len(row) - len(colmax)))]
+    return colmax
+
+def asciitable(table):
+    colmax = getmax(table)
     lines = []
     for row in table:
         line = []
@@ -36,6 +40,23 @@
         lines.append(" ".join(line))
     return "\n".join(lines)
 
+def ReSTtable(table):
+    colmax = getmax(table)
+    lines = []
+    l = ["-" * width for width in colmax]
+    l.append("")
+    l.insert(0, "")
+    sepline = "+".join(l)
+    lines.append(sepline)
+    for row in table:
+        line = [""]
+        for col,width in zip(row, colmax):
+            line.append("%%-%ds" %(width) %(col))
+        line.append("")
+        lines.append("|".join(line))
+        lines.append(sepline)
+    lines.append(sepline)
+    return "\n".join(lines)
 
 def maxtable_overview(resultset):
     tw = py.io.TerminalWriter()
@@ -114,10 +135,10 @@
                 incsize = self.get_incremental_size(result)
                 # colors work but messup table layout
                 color = incsize <= basesize and "green" or "red"
-                row.append(tw.markup(str(incsize), **{color:True}))
-                #row.append(incsize)
+                #row.append(tw.markup(str(incsize), **{color:True}))
+                row.append(incsize)
             rows.append(row)
-        tw.line(asciitable(rows))
+        tw.line(ReSTtable(rows))
 
     def run_graphic(self, plotter):        
         """ This function creates series of graphs for showing incremental



More information about the Pypy-commit mailing list