[pypy-commit] pypy default: refactor this script a little

fijal noreply at buildbot.pypy.org
Mon Oct 14 14:53:40 CEST 2013


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: 
Changeset: r67356:9bee4fc9c02b
Date: 2013-10-14 14:26 +0200
http://bitbucket.org/pypy/pypy/changeset/9bee4fc9c02b/

Log:	refactor this script a little

diff --git a/rpython/tool/gcanalyze.py b/rpython/tool/gcanalyze.py
--- a/rpython/tool/gcanalyze.py
+++ b/rpython/tool/gcanalyze.py
@@ -18,15 +18,20 @@
             start = entry[1]
             end = entry[2]
             all.append(float(end - start) / 1000000)
+    format_output(all)
+
+def format_output(all):
     avg = sum(all) / len(all)
     max_t = max(all)
-    print "AVG:", "%.1fms" % avg, "MAX:", "%.1fms" % max_t
-    buckets = [0] * (NO_BUCKETS + 1)
+    print "AVG:", "%.1fms" % avg, "MAX:", "%.1fms" % max_t, "TOTAL:" , "%.1fms" % sum(all)
+    buckets = [0] * NO_BUCKETS
     for item in all:
         bucket = int(item / max_t * NO_BUCKETS)
+        if bucket == len(buckets):
+            bucket = len(buckets) - 1
         buckets[bucket] += 1
     l1 = ["%.1fms" % ((i + 1) * max_t / NO_BUCKETS) for i in range(NO_BUCKETS)]
-    l2 = [str(i) for i in buckets[1:]]
+    l2 = [str(i) for i in buckets]
     for i, elem in enumerate(l1):
         l2[i] += " " * (len(elem) - len(l2[i]))
     print " ".join(l1)


More information about the pypy-commit mailing list