Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1143)

Side by Side Diff: bench/gen_bench_expectations.py

Issue 277163002: Adds the ability to filter bench expectations in builder/config level. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.5 # Ratio of range for upper bounds. 15 RANGE_RATIO_UPPER = 1.5 # 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_UB = 1.0 # Adds an absolute upper error to cope with small benches. 18 ERR_UB = 1.0 # Adds an absolute upper error to cope with small benches.
19 ERR_LB = 1.5 19 ERR_LB = 1.5
20 20
21 # List of bench configs to monitor. Ignore all other configs. 21 # List of bench configs to monitor. Ignore all other configs.
22 CONFIGS_TO_INCLUDE = ['simple_viewport_1000x1000', 22 CONFIGS_TO_INCLUDE = ['simple_viewport_1000x1000',
23 'simple_viewport_1000x1000_gpu', 23 'simple_viewport_1000x1000_gpu',
24 'simple_viewport_1000x1000_scalar_1.100000', 24 'simple_viewport_1000x1000_scalar_1.100000',
25 'simple_viewport_1000x1000_scalar_1.100000_gpu', 25 'simple_viewport_1000x1000_scalar_1.100000_gpu',
26 ] 26 ]
27 27
28 # List of flaky SKPs that should be excluded. 28 # List of flaky entries that should be excluded. Each entry is defined by a list
29 SKPS_TO_EXCLUDE = [ 29 # of 3 strings, corresponding to the substrings of [bench, config, builder] to
30 ] 30 # search for. A bench expectations line is excluded when each of the 3 strings
31 # in the list is a substring of the corresponding element of the given line. For
32 # instance, ['desk_yahooanswers', 'gpu', 'Ubuntu'] will skip expectation entries
33 # of SKP benchs whose name contains 'desk_yahooanswers' on all gpu-related
34 # configs of all Ubuntu builders.
35 ENTRIES_TO_EXCLUDE = [
36 ]
rmistry 2014/05/12 11:56:56 What do you think about having an easy to find JSO
31 37
32 38
33 def compute_ranges(benches): 39 def compute_ranges(benches):
34 """Given a list of bench numbers, calculate the alert range. 40 """Given a list of bench numbers, calculate the alert range.
35 41
36 Args: 42 Args:
37 benches: a list of float bench values. 43 benches: a list of float bench values.
38 44
39 Returns: 45 Returns:
40 a list of float [lower_bound, upper_bound]. 46 a list of float [lower_bound, upper_bound].
41 """ 47 """
42 minimum = min(benches) 48 minimum = min(benches)
43 maximum = max(benches) 49 maximum = max(benches)
44 diff = maximum - minimum 50 diff = maximum - minimum
45 avg = sum(benches) / len(benches) 51 avg = sum(benches) / len(benches)
46 52
47 return [minimum - diff * RANGE_RATIO_LOWER - avg * ERR_RATIO - ERR_LB, 53 return [minimum - diff * RANGE_RATIO_LOWER - avg * ERR_RATIO - ERR_LB,
48 maximum + diff * RANGE_RATIO_UPPER + avg * ERR_RATIO + ERR_UB] 54 maximum + diff * RANGE_RATIO_UPPER + avg * ERR_RATIO + ERR_UB]
49 55
50 56
51 def create_expectations_dict(revision_data_points): 57 def create_expectations_dict(revision_data_points, builder):
52 """Convert list of bench data points into a dictionary of expectations data. 58 """Convert list of bench data points into a dictionary of expectations data.
53 59
54 Args: 60 Args:
55 revision_data_points: a list of BenchDataPoint objects. 61 revision_data_points: a list of BenchDataPoint objects.
62 builder: string of the corresponding buildbot builder name.
56 63
57 Returns: 64 Returns:
58 a dictionary of this form: 65 a dictionary of this form:
59 keys = tuple of (config, bench) strings. 66 keys = tuple of (config, bench) strings.
60 values = list of float [expected, lower_bound, upper_bound] for the key. 67 values = list of float [expected, lower_bound, upper_bound] for the key.
61 """ 68 """
62 bench_dict = {} 69 bench_dict = {}
63 for point in revision_data_points: 70 for point in revision_data_points:
64 if (point.time_type or # Not walltime which has time_type '' 71 if (point.time_type or # Not walltime which has time_type ''
65 not point.config in CONFIGS_TO_INCLUDE or 72 not point.config in CONFIGS_TO_INCLUDE):
66 point.bench in SKPS_TO_EXCLUDE): 73 continue
74 to_skip = False
75 for bench_substr, config_substr, builder_substr in ENTRIES_TO_EXCLUDE:
76 if (bench_substr in point.bench and config_substr in point.config and
77 builder_substr in builder):
78 to_skip = True
79 break
80 if to_skip:
67 continue 81 continue
68 key = (point.config, point.bench) 82 key = (point.config, point.bench)
69 if key in bench_dict: 83 if key in bench_dict:
70 raise Exception('Duplicate bench entry: ' + str(key)) 84 raise Exception('Duplicate bench entry: ' + str(key))
71 bench_dict[key] = [point.time] + compute_ranges(point.per_iter_time) 85 bench_dict[key] = [point.time] + compute_ranges(point.per_iter_time)
72 86
73 return bench_dict 87 return bench_dict
74 88
75 89
76 def main(): 90 def main():
(...skipping 15 matching lines...) Expand all
92 parser.add_argument( 106 parser.add_argument(
93 '-r', '--git_revision', required=True, 107 '-r', '--git_revision', required=True,
94 help='the git hash to indicate the revision of input data to use.') 108 help='the git hash to indicate the revision of input data to use.')
95 args = parser.parse_args() 109 args = parser.parse_args()
96 110
97 builder = args.builder 111 builder = args.builder
98 112
99 data_points = bench_util.parse_skp_bench_data( 113 data_points = bench_util.parse_skp_bench_data(
100 args.input_dir, args.git_revision, args.representation_alg) 114 args.input_dir, args.git_revision, args.representation_alg)
101 115
102 expectations_dict = create_expectations_dict(data_points) 116 expectations_dict = create_expectations_dict(data_points, builder)
103 117
104 out_lines = [] 118 out_lines = []
105 keys = expectations_dict.keys() 119 keys = expectations_dict.keys()
106 keys.sort() 120 keys.sort()
107 for (config, bench) in keys: 121 for (config, bench) in keys:
108 (expected, lower_bound, upper_bound) = expectations_dict[(config, bench)] 122 (expected, lower_bound, upper_bound) = expectations_dict[(config, bench)]
109 out_lines.append('%(bench)s_%(config)s_,%(builder)s-%(representation)s,' 123 out_lines.append('%(bench)s_%(config)s_,%(builder)s-%(representation)s,'
110 '%(expected)s,%(lower_bound)s,%(upper_bound)s' % { 124 '%(expected)s,%(lower_bound)s,%(upper_bound)s' % {
111 'bench': bench, 125 'bench': bench,
112 'config': config, 126 'config': config,
113 'builder': builder, 127 'builder': builder,
114 'representation': args.representation_alg, 128 'representation': args.representation_alg,
115 'expected': expected, 129 'expected': expected,
116 'lower_bound': lower_bound, 130 'lower_bound': lower_bound,
117 'upper_bound': upper_bound}) 131 'upper_bound': upper_bound})
118 132
119 with open(args.output_file, 'w') as file_handle: 133 with open(args.output_file, 'w') as file_handle:
120 file_handle.write('\n'.join(out_lines)) 134 file_handle.write('\n'.join(out_lines))
121 135
122 136
123 if __name__ == "__main__": 137 if __name__ == "__main__":
124 main() 138 main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698