summaryrefslogtreecommitdiff
path: root/tools/parsebench.py
diff options
context:
space:
mode:
authorMagnus Ahltorp <map@kth.se>2016-11-19 12:54:17 +0100
committerMagnus Ahltorp <map@kth.se>2016-11-19 12:54:17 +0100
commit88cc9feeb5c8838aad8edc0926c82b48eaa00c6c (patch)
treec7688b5e5e3e24ee97f8d4748037e187f72db9aa /tools/parsebench.py
parentaa7be9990183d6e9a87037b88a1e33dca35304e3 (diff)
Only allocate one color per stage
Diffstat (limited to 'tools/parsebench.py')
-rwxr-xr-xtools/parsebench.py49
1 files changed, 36 insertions, 13 deletions
diff --git a/tools/parsebench.py b/tools/parsebench.py
index 671e482..067cf65 100755
--- a/tools/parsebench.py
+++ b/tools/parsebench.py
@@ -37,33 +37,56 @@ def parse_one_file(filename):
iterations = itertools.groupby(lines, lambda x: x[0])
print "<h1>%s</h1>" % (filename,)
print "<div>"
- legend = []
firsttime = True
+
+ stageorderdict = {}
+ stageorder = []
+ stages = {}
+ itemorder = {}
+
+ for (i, iteration) in iterations:
+ for (_, stage, data) in iteration:
+ if stage not in stages:
+ stageorderdict[stage] = len(stageorderdict)
+ stageorder.append(stage)
+ stages[stage] = {}
+ itemorder[stage] = []
+ for (item, useconds) in data:
+ if item not in stages[stage]:
+ itemorder[stage].append(item)
+ stages[stage][item] = len(stages[stage])
+
+ iterations = itertools.groupby(lines, lambda x: x[0])
for (i, iteration) in iterations:
print >>sys.stderr, (i, iteration)
print "<table style='border-collapse: collapse;'><tr>"
- for (stagen, (_, stage, data)) in enumerate(iteration):
- if firsttime:
- legend.append("<div><span>%s</span>" % (stage,))
+ for (_, stage, data) in iteration:
data = list(data)
for (itemn, (item, useconds)) in enumerate(data):
seconds = useconds / 1000000
- step = 50 / (len(data) - 1)
- print "<td style='width: %dpx; padding: 0; background-color: hsl(%d, 90%%, %d%%);' title='%s:%s %d'>" % (int(seconds*scale), stagen * 90, itemn * step + 40, stage, item, seconds)
- if firsttime:
- legend.append("<span style='background-color: hsl(%d, 90%%, %d%%);'>%s</span>" % (stagen * 90, itemn * step + 40, item))
+ shades = stages[stage]
+ step = 50 / (len(shades) - 1)
+ shade = shades[item]
+ stagen = stageorderdict[stage]
+ print "<td style='width: %dpx; padding: 0; background-color: hsl(%d, 90%%, %d%%);' title='%s:%s %d'>" % (int(seconds*scale), stagen * 90, shade * step + 40, stage, item, seconds)
print "&nbsp;"
print "</td>"
- if firsttime:
- legend.append("</div>")
print "</tr></table>"
- firsttime = False
print "</div>"
print "<div style='height: 30px;'>"
print "</div>"
print "<div>"
- for row in legend:
- print row
+
+ for stage in stageorder:
+ print "<div><span>%s</span>" % (stage,)
+ shades = stages[stage]
+ for item in itemorder[stage]:
+ shade = shades[item]
+ step = 50 / (len(shades) - 1)
+
+ stagen = stageorderdict[stage]
+ print "<span style='background-color: hsl(%d, 90%%, %d%%);'>%s</span>" % (stagen * 90, shade * step + 40, item)
+ print "</div>"
print "</div>"
main()