OLD | NEW |
---|---|
1 ''' | 1 ''' |
2 Created on May 16, 2011 | 2 Created on May 16, 2011 |
3 | 3 |
4 @author: bungeman | 4 @author: bungeman |
5 ''' | 5 ''' |
6 import bench_util | 6 import bench_util |
7 import getopt | 7 import getopt |
8 import httplib | 8 import httplib |
9 import itertools | 9 import itertools |
10 import json | 10 import json |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
127 elements = expectation.strip().split(',') | 127 elements = expectation.strip().split(',') |
128 if not elements[0] or elements[0].startswith('#'): | 128 if not elements[0] or elements[0].startswith('#'): |
129 continue | 129 continue |
130 if len(elements) != 5: | 130 if len(elements) != 5: |
131 raise Exception("Invalid expectation line format: %s" % | 131 raise Exception("Invalid expectation line format: %s" % |
132 expectation) | 132 expectation) |
133 bench_entry = elements[0] + ',' + elements[1] | 133 bench_entry = elements[0] + ',' + elements[1] |
134 if bench_entry in expectations: | 134 if bench_entry in expectations: |
135 raise Exception("Dup entries for bench expectation %s" % | 135 raise Exception("Dup entries for bench expectation %s" % |
136 bench_entry) | 136 bench_entry) |
137 # [<Bench_BmpConfig_TimeType>,<Platform-Alg>] -> (LB, UB) | 137 # [<Bench_BmpConfig_TimeType>,<Platform-Alg>] -> (LB, UB, EXPECTED) |
138 expectations[bench_entry] = (float(elements[-2]), | 138 expectations[bench_entry] = (float(elements[-2]), |
139 float(elements[-1])) | 139 float(elements[-1]), |
140 float(elements[-3])) | |
epoger
2014/02/19 18:51:08
Not new to this CL... but these are strange magic
benchen
2014/02/19 21:08:08
Done using the constant index approach, which is m
| |
140 | 141 |
141 def check_expectations(lines, expectations, revision, key_suffix): | 142 def check_expectations(lines, expectations, revision, key_suffix): |
142 """Check if there are benches in the given revising out of range. | 143 """Check if there are benches in the given revising out of range. |
epoger
2014/02/19 18:51:08
TODO: document function arguments, return value, a
benchen
2014/02/19 21:08:08
Done.
| |
143 """ | 144 """ |
144 # The platform for this bot, to pass to the dashboard plot. | 145 # The platform for this bot, to pass to the dashboard plot. |
145 platform = key_suffix[ : key_suffix.rfind('-')] | 146 platform = key_suffix[ : key_suffix.rfind('-')] |
146 exceptions = [] | 147 exceptions = {} |
epoger
2014/02/19 18:51:08
Please document the structure of this dictionary.
benchen
2014/02/19 21:08:08
Done.
| |
147 for line in lines: | 148 for line in lines: |
148 line_str = str(line) | 149 line_str = str(line) |
149 line_str = line_str[ : line_str.find('_{')] | 150 line_str = line_str[ : line_str.find('_{')] |
150 bench_platform_key = line_str + ',' + key_suffix | 151 bench_platform_key = line_str + ',' + key_suffix |
151 if bench_platform_key not in expectations: | 152 if bench_platform_key not in expectations: |
152 continue | 153 continue |
153 this_bench_value = lines[line] | 154 this_bench_value = lines[line] |
154 this_min, this_max = expectations[bench_platform_key] | 155 this_min, this_max, this_expected = expectations[bench_platform_key] |
155 if this_bench_value < this_min or this_bench_value > this_max: | 156 if this_bench_value < this_min or this_bench_value > this_max: |
156 exception = 'Bench %s value %s out of range [%s, %s].' % ( | 157 off_ratio = this_bench_value / this_expected |
157 bench_platform_key, this_bench_value, this_min, this_max) | 158 exception = 'Bench %s off range [%s, %s] (%s vs %s, %s%%).' % ( |
epoger
2014/02/19 18:51:08
off -> out of
benchen
2014/02/19 21:08:08
Done.
| |
158 exceptions.append(exception) | 159 bench_platform_key, this_min, this_max, this_bench_value, |
160 this_expected, (off_ratio - 1) * 100) | |
161 exceptions.setdefault(off_ratio, []).append(exception) | |
159 if exceptions: | 162 if exceptions: |
160 raise Exception('Bench values out of range:\n' + | 163 ratios = exceptions.keys() |
161 '\n'.join(exceptions)) | 164 ratios.sort(reverse=True) |
165 outputs = ['Bench values out of range:', '', 'Slower:'] | |
166 for ratio in ratios: | |
167 if ratio < 1 and 'Faster:' not in outputs: | |
epoger
2014/02/19 18:51:08
I think it might be cleaner to build two expectati
benchen
2014/02/19 21:08:08
Done.
| |
168 outputs.extend(['', 'Faster:']) | |
169 outputs.extend(exceptions[ratio]) | |
170 | |
171 raise Exception('\n'.join(outputs)) | |
162 | 172 |
163 def main(): | 173 def main(): |
164 """Parses command line and checks bench expectations.""" | 174 """Parses command line and checks bench expectations.""" |
165 try: | 175 try: |
166 opts, _ = getopt.getopt(sys.argv[1:], | 176 opts, _ = getopt.getopt(sys.argv[1:], |
167 "a:b:d:e:r:", | 177 "a:b:d:e:r:", |
168 "default-setting=") | 178 "default-setting=") |
169 except getopt.GetoptError, err: | 179 except getopt.GetoptError, err: |
170 print str(err) | 180 print str(err) |
171 usage() | 181 usage() |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
209 | 219 |
210 bench_dict = create_bench_dict(data_points) | 220 bench_dict = create_bench_dict(data_points) |
211 | 221 |
212 if bench_expectations: | 222 if bench_expectations: |
213 check_expectations(bench_dict, bench_expectations, rev, | 223 check_expectations(bench_dict, bench_expectations, rev, |
214 platform_and_alg) | 224 platform_and_alg) |
215 | 225 |
216 | 226 |
217 if __name__ == "__main__": | 227 if __name__ == "__main__": |
218 main() | 228 main() |
OLD | NEW |