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 30 matching lines...) Expand all Loading... |
41 """Given a list of bench numbers, calculate the alert range. | 41 """Given a list of bench numbers, calculate the alert range. |
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 squared_avg = avg ** 2 | 50 squared_avg = avg ** 2 |
51 <<<<<<< HEAD | |
52 avg_sum_squared = sum([bench**2 for bench in benches])/len(benches) | 51 avg_sum_squared = sum([bench**2 for bench in benches])/len(benches) |
53 std_dev = (abs(avg_sum_squared - squared_avg) + 0.05*abs(avg)) ** 0.5 | 52 std_dev = (abs(avg_sum_squared - squared_avg) + 0.05*abs(avg)) ** 0.5 |
54 ======= | |
55 avg_squared = sum([bench**2 for bench in benches])/len(benches) | |
56 std_dev = (avg_squared - squared_avg) ** 0.5 | |
57 >>>>>>> origin/master | |
58 | 53 |
59 # If the results are normally distributed, 2 standard deviations | 54 # If the results are normally distributed, 2 standard deviations |
60 # captures something like ~95% of the possible range of results I think | 55 # captures something like ~95% of the possible range of results I think |
61 return [avg - 2*std_dev, avg + 2*std_dev] | 56 return [avg - 2*std_dev, avg + 2*std_dev] |
62 | 57 |
63 | 58 |
64 def create_expectations_dict(revision_data_points, builder): | 59 def create_expectations_dict(revision_data_points, builder): |
65 """Convert list of bench data points into a dictionary of expectations data. | 60 """Convert list of bench data points into a dictionary of expectations data. |
66 | 61 |
67 Args: | 62 Args: |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 'expected': expected, | 131 'expected': expected, |
137 'lower_bound': lower_bound, | 132 'lower_bound': lower_bound, |
138 'upper_bound': upper_bound}) | 133 'upper_bound': upper_bound}) |
139 | 134 |
140 with open(args.output_file, 'w') as file_handle: | 135 with open(args.output_file, 'w') as file_handle: |
141 file_handle.write('\n'.join(out_lines)) | 136 file_handle.write('\n'.join(out_lines)) |
142 | 137 |
143 | 138 |
144 if __name__ == "__main__": | 139 if __name__ == "__main__": |
145 main() | 140 main() |
OLD | NEW |