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 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 | 42 |
43 Args: | 43 Args: |
44 benches: a list of float bench values. | 44 benches: a list of float bench values. |
45 | 45 |
46 Returns: | 46 Returns: |
47 a list of float [lower_bound, upper_bound]. | 47 a list of float [lower_bound, upper_bound]. |
48 """ | 48 """ |
49 avg = sum(benches)/len(benches) | 49 avg = sum(benches)/len(benches) |
50 minimum = min(benches) | 50 minimum = min(benches) |
51 maximum = max(benches) | 51 maximum = max(benches) |
| 52 diff = maximum - minimum |
52 | 53 |
53 return [minimum - diff*RANGE_RATIO_LOWER - avg*ERR_RATIO - ERR_LB, | 54 return [minimum - diff*RANGE_RATIO_LOWER - avg*ERR_RATIO - ERR_LB, |
54 maximum + diff*RANGE_RATIO_UPPER + avg*ERR_RATIO + ERR_UB] | 55 maximum + diff*RANGE_RATIO_UPPER + avg*ERR_RATIO + ERR_UB] |
55 | 56 |
56 | 57 |
57 def create_expectations_dict(revision_data_points, builder): | 58 def create_expectations_dict(revision_data_points, builder): |
58 """Convert list of bench data points into a dictionary of expectations data. | 59 """Convert list of bench data points into a dictionary of expectations data. |
59 | 60 |
60 Args: | 61 Args: |
61 revision_data_points: a list of BenchDataPoint objects. | 62 revision_data_points: a list of BenchDataPoint objects. |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 'expected': expected, | 130 'expected': expected, |
130 'lower_bound': lower_bound, | 131 'lower_bound': lower_bound, |
131 'upper_bound': upper_bound}) | 132 'upper_bound': upper_bound}) |
132 | 133 |
133 with open(args.output_file, 'w') as file_handle: | 134 with open(args.output_file, 'w') as file_handle: |
134 file_handle.write('\n'.join(out_lines)) | 135 file_handle.write('\n'.join(out_lines)) |
135 | 136 |
136 | 137 |
137 if __name__ == "__main__": | 138 if __name__ == "__main__": |
138 main() | 139 main() |
OLD | NEW |