浏览代码

More general code to sum times

Yentl Van Tendeloo 8 年之前
父节点
当前提交
bfcb1fb5d4
共有 1 个文件被更改,包括 7 次插入6 次删除
  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
             tottimes[func] = tottimes.get(func, 0.0) + tottime
             cumtimes[func] = cumtimes.get(func, 0.0) + cumtime
             cumtimes[func] = cumtimes.get(func, 0.0) + cumtime
 
 
+lists = [(funcname, tottimes[funcname], cumtimes[funcname]) for funcname in tottimes]
+
 c = 0
 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
         c += 1
-        if c > 30:
+        if c > int(sys.argv[3]):
             break
             break