0b45335817d391f38bd01d0b7604b59f123a6e9d
[framework/graphics/cairo.git] / perf / make-html.py
1 #!/usr/bin/python
2
3 from string import strip
4 from sys import stdin
5
6 targets = {}
7 smilies = {'slowdown': '☹' , 'speedup': '☺'}
8
9 for line in stdin:
10         line = map(strip, filter(None, line.split(' ')))
11
12         if 9 == len(line):
13                 target, name = line[0:2]
14                 factor, dir = line[-2:]
15
16                 name = name.split('-')
17                 name, size = '-'.join(name[:-1]), name[-1]
18
19                 target_tests = targets.get(target, {})
20                 name_tests = target_tests.get(name, {})
21
22                 name_tests[int(size)] = (factor, dir)
23                 target_tests[name] = name_tests
24                 targets[target] = target_tests
25
26 print '''\
27 <html><head>
28 <title>Performance Changes</title>
29 <style type="text/css">/*<![CDATA[*/
30     body { background: white; color: black; }
31     table { border-collapse: collapse; }
32
33     th, td { border: 1px solid silver; padding: 0.2em; }
34     td { text-align: center; }
35     th:first-child { text-align: left; }
36     th { background: #eee; }
37
38  /* those colors also should work for color blinds */
39     td.slowdown { background: #f93; }
40     td.speedup { background: #6f9; }
41 /*]]>*/</style>
42 </head><body>
43 <h1>Performance Changes</h1>'''
44
45 targets = targets.items()
46 targets.sort(lambda a, b: cmp(a[0], b[0]))
47
48 for target, names in targets:
49         sizes = {}
50
51         for tests in names.values():
52                 for size in tests.keys():
53                         sizes[size] = True      
54
55         sizes = sizes.keys()
56         sizes.sort()
57
58         names = names.items()
59         names.sort(lambda a, b: cmp(a[0], b[0]))
60
61         print '<h2><a name="%s">%s</a></h2>' % (target, target)
62         print '<table><thead><tr><th>&nbsp;</th>'
63
64         for size in sizes:
65                 print '<th>%s</th>' % size
66
67         print '</tr></thead><tbody>'
68
69         for name, tests in names:
70                 print '<tr><th>%s</th>' % name
71                 
72                 for size in sizes:
73                         result = tests.get(size)
74
75                         if result:
76                                 factor, dir = result
77                                 print '<td class="%s">%s %s</td>' % (
78                                         dir, factor, smilies[dir])
79
80                         else:
81                                 print '<td>&nbsp;</td>'
82
83                 print '</tr>'
84
85
86         print '</tbody></table>'
87
88 print '</body></html>'