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

antocuni at codespeak.net antocuni at codespeak.net
Tue Sep 28 18:33:08 CEST 2010


Author: antocuni
Date: Tue Sep 28 18:33:07 2010
New Revision: 77458

Modified:
   pypy/trunk/pypy/jit/tool/loopviewer.py
Log:
display the details of operations before and after optimizations


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 18:33:07 2010
@@ -31,11 +31,14 @@
         nloops, nsummary = consider_category(log, options, "jit-log-noopt-")
         print
         print 'Summary of optimized-away operations'
+        print
         diff = {}
         keys = set(summary.keys()).union(set(nsummary))
         for key in keys:
-            diff[key] = nsummary.get(key, 0) - summary.get(key, 0)
-        print_summary(diff)
+            before = nsummary.get(key, 0)
+            after = summary.get(key, 0)
+            diff[key] = (before-after, before, after)
+        print_diff(diff)
 
 def consider_category(log, options, category):
     loops = logparser.extract_category(log, category)
@@ -55,7 +58,19 @@
     ops = [(summary[key], key) for key in summary]
     ops.sort(reverse=True)
     for n, key in ops:
-        print '%4d' % n, key
+        print '%5d' % n, key
+
+def print_diff(diff):
+    ops = [(d, before, after, key) for key, (d, before, after) in diff.iteritems()]
+    ops.sort(reverse=True)
+    tot_before = 0
+    tot_after = 0
+    for d, before, after, key in ops:
+        tot_before += before
+        tot_after += after
+        print '%5d - %5d = %5d     ' % (before, after, d), key
+    print '-' * 50
+    print '%5d - %5d = %5d     ' % (tot_before, tot_after, tot_before-tot_after), 'TOTAL'
 
 if __name__ == '__main__':
     parser = optparse.OptionParser(usage="%prog loopfile [options]")



More information about the Pypy-commit mailing list