sum_times.py 620 B

123456789101112131415161718192021222324
  1. import sys
  2. tottimes = {}
  3. cumtimes = {}
  4. for l in open(sys.argv[1], "r"):
  5. r = l.rsplit(" : ", 2)
  6. if len(r) == 3:
  7. func, cumtime, tottime = r
  8. cumtime = float(cumtime)
  9. tottime = float(tottime)
  10. tottimes[func] = tottimes.get(func, 0.0) + tottime
  11. cumtimes[func] = cumtimes.get(func, 0.0) + cumtime
  12. c = 0
  13. for time, func in reversed(sorted([(tottimes[k], k) for k in tottimes])):
  14. if func.startswith("jit"):
  15. continue
  16. else:
  17. print("%s = %s (%s)" % (func, time, cumtimes[func]))
  18. c += 1
  19. if c > 30:
  20. break