diff options
author | Hakan Ardo <hakan@debian.org> | 2010-11-17 19:41:25 +0000 |
---|---|---|
committer | Hakan Ardo <hakan@debian.org> | 2010-11-17 19:41:25 +0000 |
commit | baf678c574081d15f0e409eb8d004c76e87b95c2 (patch) | |
tree | 1b7f8e03b86f24a6c8a44ece82fcdb6e5602fce4 /pypy/jit/tool/loopcounter.py | |
parent | Better name (diff) | |
download | pypy-baf678c574081d15f0e409eb8d004c76e87b95c2.tar.gz pypy-baf678c574081d15f0e409eb8d004c76e87b95c2.tar.bz2 pypy-baf678c574081d15f0e409eb8d004c76e87b95c2.zip |
svn merge -r78744:HEAD svn+ssh://hakanardo@codespeak.net/svn/pypy/trunk
Diffstat (limited to 'pypy/jit/tool/loopcounter.py')
-rw-r--r-- | pypy/jit/tool/loopcounter.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/pypy/jit/tool/loopcounter.py b/pypy/jit/tool/loopcounter.py new file mode 100644 index 0000000000..978056f797 --- /dev/null +++ b/pypy/jit/tool/loopcounter.py @@ -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) |