summaryrefslogtreecommitdiff
path: root/tools/parsebench.py
blob: acf018a406de7eb49234e4ddf6938a7ccf5ff1ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env python

# Copyright (c) 2014, NORDUnet A/S.
# See LICENSE for licensing information.

import argparse
import sys
import ast
import itertools

def parse_one_line(line):
    row = line.rstrip().split(":")
    assert row[0].startswith("mergeoutput.")
    iteration = int(row[0][12:])
    stage = row[2].strip()
    data = ast.literal_eval(row[3].strip())
    return (iteration, stage, data)

def main():
    parser = argparse.ArgumentParser(description="")
    parser.add_argument('inputfile', help="Input file")
    args = parser.parse_args()
    lines = [parse_one_line(line) for line in open(args.inputfile)]
    iterations = itertools.groupby(lines, lambda x: x[0])
    print "<!DOCTYPE html>"
    print "<html>"
    print "<head>"
    print "</head>"
    print "<body>"
    print "<div>"
    legend = []
    for (i, iteration) in iterations:
        print "<table><tr>"
        for (stagen, (_, stage, data)) in enumerate(iteration):
            if i == 0:
                legend.append("<div><span>%s</span>" % (stage,))
            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'>" % (seconds, stagen * 90, itemn * step + 40, stage, item)
                if i == 0:
                    legend.append("<span style='background-color: hsl(%d, 90%%, %d%%);'>%s</span>" % (stagen * 90, itemn * step + 40, item))
                print "&nbsp;"
                print "</td>"
            if i == 0:
                legend.append("</div>")
        print "</tr></table>"
    print "</div>"
    print "<div style='height: 30px;'>"
    print "</div>"
    print "<div>"
    for row in legend:
        print row
    print "</div>"
    print "</body>"
    print "</html>"

main()