summaryrefslogtreecommitdiff
path: root/perf/make-html.py
blob: 0b45335817d391f38bd01d0b7604b59f123a6e9d (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/python

from string import strip
from sys import stdin

targets = {}
smilies = {'slowdown': '☹' , 'speedup': '☺'}

for line in stdin:
	line = map(strip, filter(None, line.split(' ')))

	if 9 == len(line):
		target, name = line[0:2]
		factor, dir = line[-2:]

		name = name.split('-')
		name, size = '-'.join(name[:-1]), name[-1]

		target_tests = targets.get(target, {})
		name_tests = target_tests.get(name, {})

		name_tests[int(size)] = (factor, dir)
		target_tests[name] = name_tests
		targets[target] = target_tests

print '''\
<html><head>
<title>Performance Changes</title>
<style type="text/css">/*<![CDATA[*/
    body { background: white; color: black; }
    table { border-collapse: collapse; }

    th, td { border: 1px solid silver; padding: 0.2em; }
    td { text-align: center; }
    th:first-child { text-align: left; }
    th { background: #eee; }

 /* those colors also should work for color blinds */
    td.slowdown { background: #f93; }
    td.speedup { background: #6f9; }
/*]]>*/</style>
</head><body>
<h1>Performance Changes</h1>'''

targets = targets.items()
targets.sort(lambda a, b: cmp(a[0], b[0]))

for target, names in targets:
	sizes = {}

	for tests in names.values():
		for size in tests.keys():
			sizes[size] = True	

	sizes = sizes.keys()
	sizes.sort()

	names = names.items()
	names.sort(lambda a, b: cmp(a[0], b[0]))

	print '<h2><a name="%s">%s</a></h2>' % (target, target)
	print '<table><thead><tr><th>&nbsp;</th>'

	for size in sizes:
		print '<th>%s</th>' % size

	print '</tr></thead><tbody>'

	for name, tests in names:
		print '<tr><th>%s</th>' % name
		
		for size in sizes:
			result = tests.get(size)

			if result:
				factor, dir = result
				print '<td class="%s">%s %s</td>' % (
					dir, factor, smilies[dir])

			else:
				print '<td>&nbsp;</td>'

		print '</tr>'


	print '</tbody></table>'

print '</body></html>'