[pypy-svn] r79461 - in pypy/trunk/pypy/jit/tool: . test

antocuni at codespeak.net antocuni at codespeak.net
Wed Nov 24 15:06:46 CET 2010


Author: antocuni
Date: Wed Nov 24 15:06:44 2010
New Revision: 79461

Modified:
   pypy/trunk/pypy/jit/tool/log-template.gnumeric
   pypy/trunk/pypy/jit/tool/log2gnumeric.py
   pypy/trunk/pypy/jit/tool/test/test_log2gnumeric.py
Log:
add a sheet containing the number of loops and bridges alive. Draw it on the "Memory Usage" graph. Add a "Loops" graph


Modified: pypy/trunk/pypy/jit/tool/log-template.gnumeric
==============================================================================
Binary files. No diff available.

Modified: pypy/trunk/pypy/jit/tool/log2gnumeric.py
==============================================================================
--- pypy/trunk/pypy/jit/tool/log2gnumeric.py	(original)
+++ pypy/trunk/pypy/jit/tool/log2gnumeric.py	Wed Nov 24 15:06:44 2010
@@ -28,7 +28,8 @@
     xml = gzip.open('log-template.gnumeric').read()
     xml = replace_sheet(xml, 'translation-task', tasks_rows(time0, data))
     xml = replace_sheet(xml, 'gc-collect', gc_collect_rows(time0, data))
-    xml = replace_sheet(xml, 'memusage', memusage_rows(logname + '.memusage', maxtime))
+    xml = replace_sheet(xml, 'loops', loops_rows(time0, data))
+    xml = replace_sheet(xml, 'vmrss', memusage_rows(logname + '.vmrss', maxtime))
     #
     out = gzip.open(outname, 'wb')
     out.write(xml)
@@ -115,6 +116,31 @@
         clock = int(a, 16) - time0
         yield clock, 1, b
 
+
+def loops_rows(time0, data):
+    s = r"""
+\[([0-9a-f]+)\] \{jit-mem-looptoken-(alloc|free)
+(.*?)\[
+"""
+    #
+    r = re.compile(s.replace('\n', ''))
+    yield 'clock', 'total', 'loops', 'bridges'
+    loops = 0
+    bridges = 0
+    for clock, action, text in r.findall(data):
+        clock = int(clock, 16) - time0
+        if text.startswith('allocating Loop #'):
+            loops += 1
+        elif text.startswith('allocating Bridge #'):
+            bridges += 1
+        elif text.startswith('freeing Loop #'):
+            match = re.match('freeing Loop # .* with ([0-9]*) attached bridges', text)
+            loops -=1
+            bridges -= int(match.group(1))
+        total = loops+bridges
+        yield clock, loops+bridges, loops, bridges
+
+
 def memusage_rows(filename, maxtime):
     try:
         lines = open(filename).readlines()

Modified: pypy/trunk/pypy/jit/tool/test/test_log2gnumeric.py
==============================================================================
--- pypy/trunk/pypy/jit/tool/test/test_log2gnumeric.py	(original)
+++ pypy/trunk/pypy/jit/tool/test/test_log2gnumeric.py	Wed Nov 24 15:06:44 2010
@@ -73,4 +73,27 @@
     assert rows[1] == (0, 100)
     assert rows[2] == (1000, 200)
     assert rows[3] == (2000, 300)
-    
+
+def test_loops_rows():
+    log = """\
+[1000] {jit-mem-looptoken-alloc
+allocating Loop # 0
+[1001] jit-mem-looptoken-alloc}
+[2000] {jit-mem-looptoken-alloc
+allocating Loop # 1
+[2001] jit-mem-looptoken-alloc}
+[3000] {jit-mem-looptoken-alloc
+allocating Bridge # 1 of Loop # 0
+[3001] jit-mem-looptoken-alloc}
+[4000] {jit-mem-looptoken-free
+freeing Loop # 0 with 1 attached bridges
+[4001]
+"""
+    log = log.replace('\n', '')
+    rows = list(log2gnumeric.loops_rows(0x1000, log))
+    assert len(rows) == 5
+    assert rows[0] == ('clock', 'total', 'loops', 'bridges')
+    assert rows[1] == (    0x0,       1,       1,         0)
+    assert rows[2] == ( 0x1000,       2,       2,         0)
+    assert rows[3] == ( 0x2000,       3,       2,         1)
+    assert rows[4] == ( 0x3000,       1,       1,         0)



More information about the Pypy-commit mailing list