Browse Source

More general code to sum times

Yentl Van Tendeloo 6 years ago
parent
commit
bfcb1fb5d4
1 changed files with 7 additions and 6 deletions
  1. 7 6
      sum_times.py

+ 7 - 6
sum_times.py

@@ -12,12 +12,13 @@ for l in open(sys.argv[1], "r"):
             tottimes[func] = tottimes.get(func, 0.0) + tottime
             cumtimes[func] = cumtimes.get(func, 0.0) + cumtime
 
+lists = [(funcname, tottimes[funcname], cumtimes[funcname]) for funcname in tottimes]
+
 c = 0
-for time, func in reversed(sorted([(tottimes[k], k) for k in tottimes])):
-    if func.startswith("jit"):
-        continue
-    else:
-        print("%s = %s (%s)" % (func, time, cumtimes[func]))
+lists.sort(key=lambda i: i[int(sys.argv[2])])
+for func, tottime, cumtime in reversed(lists):
+    if not func.startswith("jit"):
+        print("%s = %s (%s)" % (func, tottime, cumtime))
         c += 1
-        if c > 30:
+        if c > int(sys.argv[3]):
             break