[pypy-commit] pypy default: a simple command to just print the summary

fijal noreply at buildbot.pypy.org
Tue Aug 2 14:43:09 CEST 2011


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: 
Changeset: r46200:bcb168ad82d5
Date: 2011-08-02 14:43 +0200
http://bitbucket.org/pypy/pypy/changeset/bcb168ad82d5/

Log:	a simple command to just print the summary

diff --git a/pypy/tool/logparser.py b/pypy/tool/logparser.py
--- a/pypy/tool/logparser.py
+++ b/pypy/tool/logparser.py
@@ -4,7 +4,8 @@
     python logparser.py <action> <logfilename> <output> <options...>
 
 Actions:
-    draw-time   draw a timeline image of the log (format PNG by default)
+    draw-time      draw a timeline image of the log (format PNG by default)
+    print-summary  print a summary of the log
 """
 import autopath
 import sys, re
@@ -383,6 +384,20 @@
     else:
         image.save(output)
 
+def print_summary(log, out):
+    totaltimes = gettotaltimes(log)
+    if out == '-':
+        outfile = sys.stdout
+    else:
+        outfile = open(out, "w")
+    l = totaltimes.items()
+    l.sort(cmp=lambda a, b: cmp(b[1], a[1]))
+    for a, b in l[1:]:
+        s = " " * (50 - len(a))
+        print >>outfile, a, s, str(b*100/l[0][1]) + "%"
+    if out != '-':
+        outfile.close()
+
 # ____________________________________________________________
 
 
@@ -391,6 +406,7 @@
                                         'mainwidth=', 'mainheight=',
                                         'summarywidth=', 'summarybarheight=',
                                         ]),
+    'print-summary': (print_summary, []),
     }
 
 if __name__ == '__main__':


More information about the pypy-commit mailing list