OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2014 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2014 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """ Generate bench_expectations file from a given set of bench data files. """ | 6 """ Generate bench_expectations file from a given set of bench data files. """ |
7 | 7 |
8 import argparse | 8 import argparse |
9 import bench_util | 9 import bench_util |
10 import os | 10 import os |
11 import re | 11 import re |
12 import sys | 12 import sys |
13 | 13 |
14 # Parameters for calculating bench ranges. | 14 # Parameters for calculating bench ranges. |
15 RANGE_RATIO_UPPER = 1.2 # Ratio of range for upper bounds. | 15 RANGE_RATIO_UPPER = 1.2 # Ratio of range for upper bounds. |
16 RANGE_RATIO_LOWER = 2.0 # Ratio of range for lower bounds. | 16 RANGE_RATIO_LOWER = 2.0 # Ratio of range for lower bounds. |
17 ERR_RATIO = 0.08 # Further widens the range by the ratio of average value. | 17 ERR_RATIO = 0.08 # Further widens the range by the ratio of average value. |
18 ERR_ABS = 0.5 # Adds an absolute error margin to cope with very small benches. | 18 ERR_UB = 0.5 # Adds an absolute upper error to cope with small benches. |
| 19 ERR_LB = 1.5 |
19 | 20 |
20 # List of bench configs to monitor. Ignore all other configs. | 21 # List of bench configs to monitor. Ignore all other configs. |
21 CONFIGS_TO_INCLUDE = ['simple_viewport_1000x1000', | 22 CONFIGS_TO_INCLUDE = ['simple_viewport_1000x1000', |
22 'simple_viewport_1000x1000_gpu', | 23 'simple_viewport_1000x1000_gpu', |
23 'simple_viewport_1000x1000_scalar_1.100000', | 24 'simple_viewport_1000x1000_scalar_1.100000', |
24 'simple_viewport_1000x1000_scalar_1.100000_gpu', | 25 'simple_viewport_1000x1000_scalar_1.100000_gpu', |
25 ] | 26 ] |
26 | 27 |
27 # List of flaky SKPs that should be excluded. | 28 # List of flaky SKPs that should be excluded. |
28 SKPS_TO_EXCLUDE = [ | 29 SKPS_TO_EXCLUDE = [ |
29 ] | 30 ] |
30 | 31 |
31 | 32 |
32 def compute_ranges(benches): | 33 def compute_ranges(benches): |
33 """Given a list of bench numbers, calculate the alert range. | 34 """Given a list of bench numbers, calculate the alert range. |
34 | 35 |
35 Args: | 36 Args: |
36 benches: a list of float bench values. | 37 benches: a list of float bench values. |
37 | 38 |
38 Returns: | 39 Returns: |
39 a list of float [lower_bound, upper_bound]. | 40 a list of float [lower_bound, upper_bound]. |
40 """ | 41 """ |
41 minimum = min(benches) | 42 minimum = min(benches) |
42 maximum = max(benches) | 43 maximum = max(benches) |
43 diff = maximum - minimum | 44 diff = maximum - minimum |
44 avg = sum(benches) / len(benches) | 45 avg = sum(benches) / len(benches) |
45 | 46 |
46 return [minimum - diff * RANGE_RATIO_LOWER - avg * ERR_RATIO - ERR_ABS, | 47 return [minimum - diff * RANGE_RATIO_LOWER - avg * ERR_RATIO - ERR_UB, |
47 maximum + diff * RANGE_RATIO_UPPER + avg * ERR_RATIO + 2 * ERR_ABS] | 48 maximum + diff * RANGE_RATIO_UPPER + avg * ERR_RATIO + ERR_LB] |
48 | 49 |
49 | 50 |
50 def create_expectations_dict(revision_data_points): | 51 def create_expectations_dict(revision_data_points): |
51 """Convert list of bench data points into a dictionary of expectations data. | 52 """Convert list of bench data points into a dictionary of expectations data. |
52 | 53 |
53 Args: | 54 Args: |
54 revision_data_points: a list of BenchDataPoint objects. | 55 revision_data_points: a list of BenchDataPoint objects. |
55 | 56 |
56 Returns: | 57 Returns: |
57 a dictionary of this form: | 58 a dictionary of this form: |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 'expected': expected, | 115 'expected': expected, |
115 'lower_bound': lower_bound, | 116 'lower_bound': lower_bound, |
116 'upper_bound': upper_bound}) | 117 'upper_bound': upper_bound}) |
117 | 118 |
118 with open(args.output_file, 'w') as file_handle: | 119 with open(args.output_file, 'w') as file_handle: |
119 file_handle.write('\n'.join(out_lines)) | 120 file_handle.write('\n'.join(out_lines)) |
120 | 121 |
121 | 122 |
122 if __name__ == "__main__": | 123 if __name__ == "__main__": |
123 main() | 124 main() |
OLD | NEW |