Browse Source

Updated sum_times to parse a profiling log

Yentl Van Tendeloo 8 years ago
parent
commit
0bc383399e
1 changed files with 15 additions and 9 deletions
  1. 15 9
      sum_times.py

+ 15 - 9
sum_times.py

@@ -1,14 +1,20 @@
 import sys
 
-total = 0.0
+counters = {}
 
 for l in open(sys.argv[1], "r"):
-    if sys.argv[2] in l:
-        _, t = l.rsplit(" ", 1)
-        try:
-            t = float(t)
-            total += t
-        except:
-            pass
+        r = l.rsplit(" : ", 1)
+        if len(r) == 2:
+            func, time = r
+            time = float(time)
+            counters[func] = counters.get(func, 0.0) + time
 
-print("Total for " + sys.argv[2] + " = " + str(total))
+c = 0
+for time, func in reversed(sorted([(counters[k], k) for k in counters])):
+    if func.startswith("jit"):
+        continue
+    else:
+        print("%s = %s" % (func, time))
+        c += 1
+        if c > 30:
+            break