summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsrc/bin/expedite-cmp66
1 files changed, 50 insertions, 16 deletions
diff --git a/src/bin/expedite-cmp b/src/bin/expedite-cmp
index 3b1e1b9..8acdf5f 100755
--- a/src/bin/expedite-cmp
+++ b/src/bin/expedite-cmp
@@ -6,6 +6,10 @@ import os.path
6import csv 6import csv
7from optparse import OptionParser 7from optparse import OptionParser
8 8
9fmttext = '%(value)7.2f (%(percentual)+6.1f%%)'
10fmthtml = '%(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>'
11
12
9parser = OptionParser(usage="%prog [options] <reference> <file2> .. <fileN>", 13parser = OptionParser(usage="%prog [options] <reference> <file2> .. <fileN>",
10 description="""\ 14 description="""\
11Generate reports comparing two or more outputs of expedite. 15Generate reports comparing two or more outputs of expedite.
@@ -23,10 +27,12 @@ parser.add_option("-r", "--report",
23 "[default=%default]"), 27 "[default=%default]"),
24 action="store", type="choice", default="text", 28 action="store", type="choice", default="text",
25 choices=["text", "html"]) 29 choices=["text", "html"])
26parser.add_option("-p", "--percentual", 30parser.add_option("-F", "--format",
27 help=("show percentual instead of raw numbers for " 31 help=("format to use as python format string, "
28 "non-reference values."), 32 "valid keys are: value and percentual. "
29 action="store_true", default=False) 33 "[defaults: html=\"%s\", text=\"%s\"]" %
34 (fmthtml, fmttext)),
35 action="store", type="str", default=None)
30parser.add_option("-C", "--no-color", dest="color", 36parser.add_option("-C", "--no-color", dest="color",
31 help="do not use color in reports.", 37 help="do not use color in reports.",
32 action="store_false", default=True) 38 action="store_false", default=True)
@@ -35,6 +41,11 @@ options, files = parser.parse_args()
35if len(files) < 2: 41if len(files) < 2:
36 raise SystemExit("need at least 2 files to compare") 42 raise SystemExit("need at least 2 files to compare")
37 43
44if options.format is None:
45 if options.report == "html":
46 options.format = fmthtml
47 else:
48 options.format = fmttext
38 49
39ref_f = files[0] 50ref_f = files[0]
40others_f = files[1:] 51others_f = files[1:]
@@ -54,10 +65,14 @@ for f in files:
54def report_text(): 65def report_text():
55 test_name_fmt = "%%%ds:" % max_test_name 66 test_name_fmt = "%%%ds:" % max_test_name
56 67
68 fmtsize = len(options.format % {"value": 12345.67, "percentual": 1234.56})
69 hdrfmt = "%%%d.%ds" % (fmtsize, fmtsize)
70
57 print test_name_fmt % "\\", 71 print test_name_fmt % "\\",
58 for f in files: 72 print "%7.7s" % (files[0][-7:],),
73 for f in files[1:]:
59 n, e = os.path.splitext(f) 74 n, e = os.path.splitext(f)
60 print "%7.7s" % n[-7:], 75 print hdrfmt % n[-fmtsize:],
61 print 76 print
62 77
63 if options.color and os.environ.get("TERM", "") == "xterm": 78 if options.color and os.environ.get("TERM", "") == "xterm":
@@ -91,10 +106,10 @@ def report_text():
91 else: 106 else:
92 c = color_equal 107 c = color_equal
93 108
94 if options.percentual: 109 fmt = options.format % {"value": val, "percentual": percent * 100}
95 print "%s%+6.1f%%%s" % (c, (percent * 100), color_reset), 110 if len(fmt) < fmtsize:
96 else: 111 fmt = hdrfmt % fmt
97 print "%s%7.2f%s" % (c, val, color_reset), 112 print "%s%s%s" % (c, fmt, color_reset),
98 113
99 print 114 print
100 115
@@ -116,11 +131,27 @@ def report_html():
116 <title>expedite comparison sheet: %(files)s</title> 131 <title>expedite comparison sheet: %(files)s</title>
117 </head> 132 </head>
118 <style type="text/css"> 133 <style type="text/css">
134 table
135 {
136 border: 1px solid black;
137 border-collapse: collapse;
138 }
139 thead
140 {
141 border-bottom: 1px solid black;
142 }
143 tr.overall-results
144 {
145 border-top: 1px solid black;
146 font-weight: bold;
147 }
119 td.value, td.value-reference, td.value-missing, td.value-good, td.value-bad, td.value-equal 148 td.value, td.value-reference, td.value-missing, td.value-good, td.value-bad, td.value-equal
120 { 149 {
121 font-family: courier, monospaced; 150 font-family: courier, monospaced;
122 font-size: 10pt; 151 font-size: 10pt;
123 text-align: right; 152 text-align: right;
153 border-left: 1px solid black;
154 border-bottom: 1px dashed #ccc;
124 } 155 }
125 td.test-name, thead tr td { text-align: right; }\ 156 td.test-name, thead tr td { text-align: right; }\
126""" 157"""
@@ -133,6 +164,7 @@ def report_html():
133 { 164 {
134 font-weight: bold; 165 font-weight: bold;
135 background-color: #d9d9d9; 166 background-color: #d9d9d9;
167 border-bottom: 1px dashed #ccc;
136 } 168 }
137""" 169"""
138 170
@@ -160,11 +192,16 @@ def report_html():
160 192
161 def print_row(test): 193 def print_row(test):
162 ref_val = data[ref_f][test] 194 ref_val = data[ref_f][test]
195 if "EVAS SPEED" in test.upper():
196 extra_cls = ' class="overall-results"'
197 else:
198 extra_cls = ""
199
163 print """\ 200 print """\
164 <tr> 201 <tr%s>
165 <td class="test-name">%s</td> 202 <td class="test-name">%s</td>
166 <td class="value-reference">%7.2f</td>\ 203 <td class="value-reference">%7.2f</td>\
167""" % (test, ref_val) 204""" % (extra_cls, test, ref_val)
168 205
169 for f in others_f: 206 for f in others_f:
170 try: 207 try:
@@ -183,10 +220,7 @@ def report_html():
183 else: 220 else:
184 c = 'equal' 221 c = 'equal'
185 222
186 if options.percentual: 223 v = options.format % {"value": val, "percentual": percent * 100}
187 v = "%+6.1f%%" % (percent * 100)
188 else:
189 v = "%7.2f" % val
190 224
191 print """\ 225 print """\
192 <td class="value-%s">%s</td>\ 226 <td class="value-%s">%s</td>\