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

antocuni at codespeak.net antocuni at codespeak.net
Wed Nov 17 15:29:36 CET 2010


Author: antocuni
Date: Wed Nov 17 15:29:34 2010
New Revision: 79195

Added:
   pypy/trunk/pypy/jit/tool/loopcounter.py   (contents, props changed)
Log:
a tool to parse a logfile and produce a csv with the number of loops and
bridges as a function of the timestamp (useful for building graphs)



Added: pypy/trunk/pypy/jit/tool/loopcounter.py
==============================================================================
--- (empty file)
+++ pypy/trunk/pypy/jit/tool/loopcounter.py	Wed Nov 17 15:29:34 2010
@@ -0,0 +1,44 @@
+#!/usr/bin/env python
+"""
+Parse and display the traces produced by pypy-c-jit when PYPYLOG is set.
+"""
+
+import autopath
+import py
+import sys
+import optparse
+
+def get_timestamp(line):
+    import re
+    match = re.match(r'\[([0-9a-f]*)\] .*', line)
+    return int(match.group(1), 16)
+
+def main(logfile, options):
+    log = open(logfile)
+    loops = 0
+    bridges = 0
+    time0 = None
+    print 'timestamp,total,loops,bridges'
+    for line in log:
+        if time0 is None and line.startswith('['):
+            time0 = get_timestamp(line)
+        if '{jit-log-opt-' in line:
+            time_now = get_timestamp(line)
+            if '{jit-log-opt-loop' in line:
+                loops += 1
+            elif '{jit-log-opt-bridge' in line:
+                bridges += 1
+            else:
+                assert False, 'unknown category %s' % line
+            total = loops+bridges
+            timestamp = time_now - time0
+            print '%d,%d,%d,%d' % (timestamp, total, loops, bridges)
+
+if __name__ == '__main__':
+    parser = optparse.OptionParser(usage="%prog loopfile [options]")
+    options, args = parser.parse_args()
+    if len(args) != 1:
+        parser.print_help()
+        sys.exit(2)
+
+    main(args[0], options)



More information about the Pypy-commit mailing list