[pypy-svn] r77446 - pypy/trunk/pypy/jit/tool

antocuni at codespeak.net antocuni at codespeak.net
Tue Sep 28 15:03:58 CEST 2010


Author: antocuni
Date: Tue Sep 28 15:03:57 2010
New Revision: 77446

Modified:
   pypy/trunk/pypy/jit/tool/loopviewer.py
Log:
add the possibility to consider all loops in a file, and to print an accumulated summary


Modified: pypy/trunk/pypy/jit/tool/loopviewer.py
==============================================================================
--- pypy/trunk/pypy/jit/tool/loopviewer.py	(original)
+++ pypy/trunk/pypy/jit/tool/loopviewer.py	Tue Sep 28 15:03:57 2010
@@ -14,17 +14,24 @@
 from pypy.rpython.lltypesystem import llmemory, lltype
 
 def main(loopfile, options):
-    print 'Loading loop:'
+    print 'Loading file:'
     log = logparser.parse_log_file(loopfile)
     print
     loops = logparser.extract_category(log, "jit-log-opt-")
-    inp = loops[options.loopnum]
-    loop = parse(inp, no_namespace=True)
+    if options.loopnum is None:
+        input_loops = loops
+    else:
+        input_loops = [loops[options.loopnum]]
+    loops = [parse(inp, no_namespace=True) for inp in input_loops]
     if not options.quiet:
-        loop.show()
+        for loop in loops:
+            loop.show()
     if options.summary:
+        summary = {}
+        for loop in loops:
+            summary = loop.summary(summary)
         print 'Summary:'
-        print_summary(loop.summary())
+        print_summary(summary)
 
 def print_summary(summary):
     keys = sorted(summary)
@@ -35,8 +42,10 @@
     parser = optparse.OptionParser(usage="%prog loopfile [options]")
     parser.add_option('-n', '--loopnum', dest='loopnum', default=-1, metavar='N', type=int,
                       help='show the loop number N [default: last]')
+    parser.add_option('-a', '--all', dest='loopnum', action='store_const', const=None,
+                      help='show all loops in the file')
     parser.add_option('-s', '--summary', dest='summary', action='store_true', default=False,
-                      help='print a summary of the operations in the loop')
+                      help='print a summary of the operations in the loop(s)')
     parser.add_option('-q', '--quiet', dest='quiet', action='store_true', default=False,
                       help='do not show the graphical representation of the loop')
     



More information about the Pypy-commit mailing list