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