Transform the output of cairo-perf-diff into HTML

This commit is contained in:
Mathias Hasselmann 2007-03-14 21:41:40 +01:00
parent f1dd48475a
commit c40be43aef
3 changed files with 111 additions and 6 deletions

View file

@ -60,6 +60,11 @@ $(top_builddir)/src/libcairo.la:
perf: cairo-perf FORCE
./cairo-perf
html: index.html
index.html: cairo-perf
./cairo-perf-diff -h HEAD > $@
EXTRA_VG_FLAGS = $(CAIRO_EXTRA_VALGRIND_FLAGS)
VG_MEMCHECK_FLAGS = \
--tool=memcheck \
@ -68,7 +73,8 @@ VG_MEMCHECK_FLAGS = \
VG_CALLGRIND_FLAGS = \
--tool=callgrind
CLEANFILES = \
valgrind-log
valgrind-log \
index.html
perf-valgrind: cairo-perf FORCE
$(top_srcdir)/libtool --mode=execute \

View file

@ -42,10 +42,15 @@ if [ $# -eq 0 ] || [ "$1" = "--" ]; then
usage
fi
if [ "$1" = "-f" ]; then
force_cairo_perf="true"
shift 1
fi
while true; do
case $1 in
-f|--force) force_cairo_perf="true";;
-h|--html) html_output="true";;
*) break;;
esac
shift
done
if [ $# -eq 1 ] || [ "$2" = "--" ]; then
old="$1^"
@ -175,4 +180,9 @@ if [ ! -e $new ]; then
new=$(rev2perf $new)
fi
$CAIRO_DIR/perf/cairo-perf-diff-files $old $new
if [ "$html_output" != "true" ]; then
$CAIRO_DIR/perf/cairo-perf-diff-files $old $new
else
$CAIRO_DIR/perf/cairo-perf-diff-files $old $new |
$CAIRO_DIR/perf/make-html.py
fi

89
perf/make-html.py Executable file
View file

@ -0,0 +1,89 @@
#!/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[*/
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>'