Commits

Carl Friedrich Bolz  committed 91748fc Draft

do parsing manually. Also stop counting virtual_ref as news

  • Participants
  • Parent commits ba23d7c

Comments (0)

Files changed (1)

     'new_array': 'new',
     'newstr': 'new',
     'new_with_vtable': 'new',
-    'virtual_ref': 'new',
     'guard_class': 'guard',
     'guard_nonnull_class': 'guard',
 }
 
 all_categories = 'new get set guard numeric rest'.split()
 
-def summarize(self, adding_insns={}):    # for debugging
+def extract_opnames(loop):
+    loop = loop.splitlines()
+    for line in loop:
+        if line.startswith('#') or line.startswith("[") or "end of the loop" in line:
+            continue
+        frontpart, paren, _ = line.partition("(")
+        assert paren
+        if " = " in frontpart:
+            yield frontpart.split(" = ", 1)[1]
+        elif ": " in frontpart:
+            yield frontpart.split(": ", 1)[1]
+        else:
+            yield frontpart
+
+def summarize(loop, adding_insns={}):    # for debugging
     insns = adding_insns.copy()
-    for op in self._all_operations(omit_finish=True):
-        opname = op.getopname()
+    seen_label = True
+    if "label" in loop:
+        seen_label = False
+    for opname in extract_opnames(loop):
+        if not seen_label:
+            if opname == 'label':
+                seen_label = True
+            else:
+                assert categories.get(opname, "rest") == "get"
+                continue
         if opname.startswith("int_") or opname.startswith("float_"):
             opname = "numeric"
         else:
             opname = categories.get(opname, 'rest')
         insns[opname] = insns.get(opname, 0) + 1
+    assert seen_label
     return insns
 
 def compute_summary_diff(loopfile, options):
+    print loopfile
     log = logparser.parse_log_file(loopfile)
     loops, summary = consider_category(log, options, "jit-log-opt-")
 
         before = nsummary[key]
         after = summary[key]
         diff[key] = (before-after, before, after)
-    return summary, diff
+    return len(loops), summary, diff
 
 def main(loopfile, options):
-    summary, diff = compute_summary_diff(loopfile, options)
+    _, summary, diff = compute_summary_diff(loopfile, options)
 
     print
     print 'Summary:'
         input_loops = loops
     else:
         input_loops = [loops[options.loopnum]]
-    loops = [parse(inp, no_namespace=True, nonstrict=True)
-             for inp in input_loops]
     summary = dict.fromkeys(all_categories, 0)
     for loop in loops:
         summary = summarize(loop, summary)
     all.sort()
     with file("logs/summary.csv", "w") as f:
         csv_writer = csv.writer(f)
-        row = ["exe", "bench"]
+        row = ["exe", "bench", "number of loops"]
         for cat in all_categories:
             row.append(cat + " before")
             row.append(cat + " after")
         csv_writer.writerow(row)
         print row
         for exe, bench, log in all:
-            summary, diff = compute_summary_diff("logs/" + log, options)
+            num_loops, summary, diff = compute_summary_diff("logs/" + log, options)
             print diff
             print exe, bench, summary
-            row = [exe, bench]
+            row = [exe, bench, num_loops]
             for cat in all_categories:
                 difference, before, after = diff[cat]
                 row.append(before)