| 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 = 1.0 # Ratio of range for upper and lower bounds. | 15 RANGE_RATIO_UPPER = 1.0 # Ratio of range for upper bounds. |
| 16 RANGE_RATIO_LOWER = 1.5 # Ratio of range for lower bounds. |
| 16 ERR_RATIO = 0.05 # Further widens the range by the ratio of average value. | 17 ERR_RATIO = 0.05 # 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. |
| 17 | 19 |
| 18 # List of bench configs to monitor. Ignore all other configs. | 20 # List of bench configs to monitor. Ignore all other configs. |
| 19 CONFIGS_TO_INCLUDE = ['simple_viewport_1000x1000', | 21 CONFIGS_TO_INCLUDE = ['simple_viewport_1000x1000', |
| 20 'simple_viewport_1000x1000_gpu', | 22 'simple_viewport_1000x1000_gpu', |
| 21 'simple_viewport_1000x1000_scalar_1.100000', | 23 'simple_viewport_1000x1000_scalar_1.100000', |
| 22 'simple_viewport_1000x1000_scalar_1.100000_gpu', | 24 'simple_viewport_1000x1000_scalar_1.100000_gpu', |
| 23 ] | 25 ] |
| 24 | 26 |
| 25 | 27 |
| 26 def compute_ranges(benches): | 28 def compute_ranges(benches): |
| 27 """Given a list of bench numbers, calculate the alert range. | 29 """Given a list of bench numbers, calculate the alert range. |
| 28 | 30 |
| 29 Args: | 31 Args: |
| 30 benches: a list of float bench values. | 32 benches: a list of float bench values. |
| 31 | 33 |
| 32 Returns: | 34 Returns: |
| 33 a list of float [lower_bound, upper_bound]. | 35 a list of float [lower_bound, upper_bound]. |
| 34 """ | 36 """ |
| 35 minimum = min(benches) | 37 minimum = min(benches) |
| 36 maximum = max(benches) | 38 maximum = max(benches) |
| 37 diff = maximum - minimum | 39 diff = maximum - minimum |
| 38 avg = sum(benches) / len(benches) | 40 avg = sum(benches) / len(benches) |
| 39 | 41 |
| 40 return [minimum - diff * RANGE_RATIO - avg * ERR_RATIO, | 42 return [minimum - diff * RANGE_RATIO_LOWER - avg * ERR_RATIO - ERR_ABS, |
| 41 maximum + diff * RANGE_RATIO + avg * ERR_RATIO] | 43 maximum + diff * RANGE_RATIO_UPPER + avg * ERR_RATIO + ERR_ABS] |
| 42 | 44 |
| 43 | 45 |
| 44 def create_expectations_dict(revision_data_points): | 46 def create_expectations_dict(revision_data_points): |
| 45 """Convert list of bench data points into a dictionary of expectations data. | 47 """Convert list of bench data points into a dictionary of expectations data. |
| 46 | 48 |
| 47 Args: | 49 Args: |
| 48 revision_data_points: a list of BenchDataPoint objects. | 50 revision_data_points: a list of BenchDataPoint objects. |
| 49 | 51 |
| 50 Returns: | 52 Returns: |
| 51 a dictionary of this form: | 53 a dictionary of this form: |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 'expected': expected, | 109 'expected': expected, |
| 108 'lower_bound': lower_bound, | 110 'lower_bound': lower_bound, |
| 109 'upper_bound': upper_bound}) | 111 'upper_bound': upper_bound}) |
| 110 | 112 |
| 111 with open(args.output_file, 'w') as file_handle: | 113 with open(args.output_file, 'w') as file_handle: |
| 112 file_handle.write('\n'.join(out_lines)) | 114 file_handle.write('\n'.join(out_lines)) |
| 113 | 115 |
| 114 | 116 |
| 115 if __name__ == "__main__": | 117 if __name__ == "__main__": |
| 116 main() | 118 main() |
| OLD | NEW |