[pypy-commit] pypy default: add pretty formatting
fijal
noreply at buildbot.pypy.org
Tue Oct 15 10:20:35 CEST 2013
Author: Maciej Fijalkowski <fijall at gmail.com>
Branch:
Changeset: r67384:6eea90d83440
Date: 2013-10-15 10:19 +0200
http://bitbucket.org/pypy/pypy/changeset/6eea90d83440/
Log: add pretty formatting
diff --git a/rpython/tool/gcanalyze.py b/rpython/tool/gcanalyze.py
--- a/rpython/tool/gcanalyze.py
+++ b/rpython/tool/gcanalyze.py
@@ -10,7 +10,7 @@
NO_BUCKETS = 8
-def main(arg):
+def main(arg, plot=False):
log = parse_log(open(arg).readlines())
all = []
for entry in log:
@@ -18,12 +18,13 @@
start = entry[1]
end = entry[2]
all.append(float(end - start) / 1000000)
- format_output(all)
+ format_output(all, plot=plot)
-def format_output(all):
+def format_output(all, plot=False):
avg = sum(all) / len(all)
max_t = max(all)
print "AVG:", "%.1fms" % avg, "MAX:", "%.1fms" % max_t, "TOTAL:" , "%.1fms" % sum(all)
+ print
buckets = [0] * NO_BUCKETS
for item in all:
bucket = int(item / max_t * NO_BUCKETS)
@@ -34,8 +35,20 @@
l2 = [str(i) for i in buckets]
for i, elem in enumerate(l1):
l2[i] += " " * (len(elem) - len(l2[i]))
- print " ".join(l1)
- print " ".join(l2)
+ if plot:
+ l3 = ["+"]
+ for i, elem in enumerate(l1):
+ l3.append("-" * len(elem) + "+")
+ l1.insert(0, "")
+ l2.insert(0, "")
+ print "".join(l3)
+ print "|".join(l1) + "|"
+ print "".join(l3)
+ print "|".join(l2) + "|"
+ print "".join(l3)
+ else:
+ print " ".join(l1)
+ print " ".join(l2)
if __name__ == '__main__':
if len(sys.argv) < 2 or len(sys.argv) > 3:
@@ -54,4 +67,4 @@
sys.exit(1)
else:
arg = sys.argv[1]
- main(arg)
+ main(arg, plot=plot)
More information about the pypy-commit
mailing list