Compare commits
3 Commits
master
...
devs/lauro
Author | SHA1 | Date |
---|---|---|
|
908c95ba85 | |
|
a873c115e0 | |
|
5f0cc9df1d |
|
@ -1,10 +1,13 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
import csv
|
import csv
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
|
from collections import defaultdict
|
||||||
|
|
||||||
fmttext = '%(value)7.2f (%(percentual)+6.1f%%)'
|
fmttext = '%(value)7.2f (%(percentual)+6.1f%%)'
|
||||||
fmthtml = '%(value)7.2f <span style="color: #666; width: 55pt; display: inline-block; text-align: right; text-shadow: #999 1px 1px 3px;">(%(percentual)+0.1f%%)</span>'
|
fmthtml = '%(value)7.2f <span style="color: #666; width: 55pt; display: inline-block; text-align: right; text-shadow: #999 1px 1px 3px;">(%(percentual)+0.1f%%)</span>'
|
||||||
|
@ -62,18 +65,30 @@ for f in files:
|
||||||
d[t] = float(row[0])
|
d[t] = float(row[0])
|
||||||
max_test_name = max(len(t), max_test_name)
|
max_test_name = max(len(t), max_test_name)
|
||||||
|
|
||||||
|
# Insert averages
|
||||||
|
data['average'] = defaultdict(list)
|
||||||
|
for f in others_f:
|
||||||
|
for test in data[f]:
|
||||||
|
data['average'][test].append(data[f][test])
|
||||||
|
for test in data['average']:
|
||||||
|
values = data['average'][test]
|
||||||
|
data['average'][test] = sum(values)/len(values)
|
||||||
|
|
||||||
|
others_f.insert(0, 'average')
|
||||||
|
|
||||||
def report_text():
|
def report_text():
|
||||||
test_name_fmt = "%%%ds:" % max_test_name
|
test_name_fmt = "%%%ds:" % max_test_name
|
||||||
|
|
||||||
fmtsize = len(options.format % {"value": 12345.67, "percentual": 1234.56})
|
fmtsize = len(options.format % {"value": 12345.67, "percentual": 1234.56})
|
||||||
hdrfmt = "%%%d.%ds" % (fmtsize, fmtsize)
|
hdrfmt = "%%%d.%ds" % (fmtsize, fmtsize)
|
||||||
|
|
||||||
print test_name_fmt % "\\",
|
print(test_name_fmt % "Files", end=' ')
|
||||||
print "%7.7s" % (files[0][-7:],),
|
first_filename, _ = os.path.splitext(files[0])
|
||||||
|
print("%7.7s" % (first_filename[-7:],), end=' ')
|
||||||
for f in files[1:]:
|
for f in files[1:]:
|
||||||
n, e = os.path.splitext(f)
|
n, e = os.path.splitext(f)
|
||||||
print hdrfmt % n[-fmtsize:],
|
print(hdrfmt % n[-fmtsize:], end=' ')
|
||||||
print
|
print()
|
||||||
|
|
||||||
if options.color and os.environ.get("TERM", "") in (
|
if options.color and os.environ.get("TERM", "") in (
|
||||||
"xterm", "xterm-color", "rxvt", "rxvt-unicode", "screen",
|
"xterm", "xterm-color", "rxvt", "rxvt-unicode", "screen",
|
||||||
|
@ -90,14 +105,14 @@ def report_text():
|
||||||
|
|
||||||
|
|
||||||
def print_row(test):
|
def print_row(test):
|
||||||
print test_name_fmt % test,
|
print(test_name_fmt % test, end=' ')
|
||||||
ref_val = data[ref_f][test]
|
ref_val = data[ref_f][test]
|
||||||
print "%7.2f" % ref_val,
|
print("%7.2f" % ref_val, end=' ')
|
||||||
for f in others_f:
|
for f in others_f:
|
||||||
try:
|
try:
|
||||||
val = data[f][test]
|
val = data[f][test]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
print "-?????-",
|
print("-?????-", end=' ')
|
||||||
continue
|
continue
|
||||||
|
|
||||||
percent = (val - ref_val) / ref_val
|
percent = (val - ref_val) / ref_val
|
||||||
|
@ -111,9 +126,9 @@ def report_text():
|
||||||
fmt = options.format % {"value": val, "percentual": percent * 100}
|
fmt = options.format % {"value": val, "percentual": percent * 100}
|
||||||
if len(fmt) < fmtsize:
|
if len(fmt) < fmtsize:
|
||||||
fmt = hdrfmt % fmt
|
fmt = hdrfmt % fmt
|
||||||
print "%s%s%s" % (c, fmt, color_reset),
|
print("%s%s%s" % (c, fmt, color_reset), end=' ')
|
||||||
|
|
||||||
print
|
print()
|
||||||
|
|
||||||
for t in tests:
|
for t in tests:
|
||||||
print_row(t)
|
print_row(t)
|
||||||
|
@ -123,7 +138,8 @@ def report_html():
|
||||||
import time
|
import time
|
||||||
|
|
||||||
fnames = [os.path.basename(f) for f in files]
|
fnames = [os.path.basename(f) for f in files]
|
||||||
print """\
|
fnames.insert(1, 'Average')
|
||||||
|
print("""\
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
|
||||||
|
@ -156,9 +172,9 @@ def report_html():
|
||||||
border-bottom: 1px dashed #ccc;
|
border-bottom: 1px dashed #ccc;
|
||||||
}
|
}
|
||||||
td.test-name, thead tr td { text-align: right; }\
|
td.test-name, thead tr td { text-align: right; }\
|
||||||
"""
|
""")
|
||||||
if options.color:
|
if options.color:
|
||||||
print """\
|
print("""\
|
||||||
td.value-good { background-color: #aaffaa; }
|
td.value-good { background-color: #aaffaa; }
|
||||||
td.value-bad { background-color: #ffaaaa; }
|
td.value-bad { background-color: #ffaaaa; }
|
||||||
td.value-missing { background-color: #ffffaa; }
|
td.value-missing { background-color: #ffffaa; }
|
||||||
|
@ -168,9 +184,9 @@ def report_html():
|
||||||
background-color: #d9d9d9;
|
background-color: #d9d9d9;
|
||||||
border-bottom: 1px dashed #ccc;
|
border-bottom: 1px dashed #ccc;
|
||||||
}
|
}
|
||||||
"""
|
""")
|
||||||
|
|
||||||
print """
|
print("""
|
||||||
</style>
|
</style>
|
||||||
<body>
|
<body>
|
||||||
<p>Comparison sheet for %(files)s, created at %(date)s.</p>
|
<p>Comparison sheet for %(files)s, created at %(date)s.</p>
|
||||||
|
@ -180,17 +196,17 @@ def report_html():
|
||||||
<td>\\</td>\
|
<td>\\</td>\
|
||||||
""" % {"files": ", ".join(fnames),
|
""" % {"files": ", ".join(fnames),
|
||||||
"date": time.asctime(),
|
"date": time.asctime(),
|
||||||
}
|
})
|
||||||
|
|
||||||
for f in fnames:
|
for f in fnames:
|
||||||
print """\
|
print("""\
|
||||||
<td>%s</td>\
|
<td>%s</td>\
|
||||||
""" % f
|
""" % f)
|
||||||
print """\
|
print("""\
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>\
|
<tbody>\
|
||||||
"""
|
""")
|
||||||
|
|
||||||
def print_row(test):
|
def print_row(test):
|
||||||
ref_val = data[ref_f][test]
|
ref_val = data[ref_f][test]
|
||||||
|
@ -199,19 +215,19 @@ def report_html():
|
||||||
else:
|
else:
|
||||||
extra_cls = ""
|
extra_cls = ""
|
||||||
|
|
||||||
print """\
|
print("""\
|
||||||
<tr%s>
|
<tr%s>
|
||||||
<td class="test-name">%s</td>
|
<td class="test-name">%s</td>
|
||||||
<td class="value-reference">%7.2f</td>\
|
<td class="value-reference">%7.2f</td>\
|
||||||
""" % (extra_cls, test, ref_val)
|
""" % (extra_cls, test, ref_val))
|
||||||
|
|
||||||
for f in others_f:
|
for f in others_f:
|
||||||
try:
|
try:
|
||||||
val = data[f][test]
|
val = data[f][test]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
print """\
|
print("""\
|
||||||
<td class="value-missing">-?????-</td>\
|
<td class="value-missing">-?????-</td>\
|
||||||
"""
|
""")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
percent = (val - ref_val) / ref_val
|
percent = (val - ref_val) / ref_val
|
||||||
|
@ -224,23 +240,23 @@ def report_html():
|
||||||
|
|
||||||
v = options.format % {"value": val, "percentual": percent * 100}
|
v = options.format % {"value": val, "percentual": percent * 100}
|
||||||
|
|
||||||
print """\
|
print("""\
|
||||||
<td class="value-%s">%s</td>\
|
<td class="value-%s">%s</td>\
|
||||||
""" % (c, v)
|
""" % (c, v))
|
||||||
|
|
||||||
print """\
|
print("""\
|
||||||
</tr>\
|
</tr>\
|
||||||
"""
|
""")
|
||||||
|
|
||||||
for t in tests:
|
for t in tests:
|
||||||
print_row(t)
|
print_row(t)
|
||||||
|
|
||||||
print """\
|
print("""\
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
"""
|
""")
|
||||||
|
|
||||||
if options.report == "text":
|
if options.report == "text":
|
||||||
report_text()
|
report_text()
|
||||||
|
|
Loading…
Reference in New Issue