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

Side by Side Diff: bench/gen_bench_ranges.py

Issue 16858015: Adds microbench range generation option; renames file appropriately. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | bench/gen_skp_ranges.py » ('j') | 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) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be found 3 # Use of this source code is governed by a BSD-style license that can be found
4 # in the LICENSE file. 4 # in the LICENSE file.
5 5
6 """ Analyze recent SkPicture bench data, and output suggested ranges. 6 """ Analyze recent SkPicture or Microbench data, and output suggested ranges.
7 7
8 The outputs can be edited and pasted to bench_expectations.txt to trigger 8 The outputs can be edited and pasted to bench_expectations.txt to trigger
9 buildbot alerts if the actual benches are out of range. Details are documented 9 buildbot alerts if the actual benches are out of range. Details are documented
10 in the .txt file. 10 in the .txt file.
11 11
12 Currently the easiest way to update bench_expectations.txt is to delete all skp 12 Currently the easiest way to batch update bench_expectations.txt is to delete
13 bench lines, run this script, and redirect outputs (">>") to be added to the 13 all bench lines, run this script, and redirect outputs (">>") to be added to the
14 .txt file. 14 .txt file.
15 TODO(bensong): find a better way for updating the bench lines in place. 15 You can also just manually change a few lines of interest, of course.
16 16
17 Note: since input data are stored in Google Storage, you will need to set up 17 Note: since input data are stored in Google Storage, you will need to set up
18 the corresponding library. 18 the corresponding library.
19 See http://developers.google.com/storage/docs/gspythonlibrary for details. 19 See http://developers.google.com/storage/docs/gspythonlibrary for details.
20 """ 20 """
21 21
22 __author__ = 'bensong@google.com (Ben Chen)' 22 __author__ = 'bensong@google.com (Ben Chen)'
23 23
24 import bench_util 24 import bench_util
25 import boto 25 import boto
(...skipping 30 matching lines...) Expand all
56 56
57 # Template for gsutil uri. 57 # Template for gsutil uri.
58 GOOGLE_STORAGE_URI_SCHEME = 'gs' 58 GOOGLE_STORAGE_URI_SCHEME = 'gs'
59 URI_BUCKET = 'chromium-skia-gm' 59 URI_BUCKET = 'chromium-skia-gm'
60 60
61 # Constants for optparse. 61 # Constants for optparse.
62 USAGE_STRING = 'USAGE: %s [options]' 62 USAGE_STRING = 'USAGE: %s [options]'
63 HOWTO_STRING = """ 63 HOWTO_STRING = """
64 Feel free to revise PLATFORMS for your own needs. The default is the most common 64 Feel free to revise PLATFORMS for your own needs. The default is the most common
65 combination that we care most about. Platforms that did not run bench_pictures 65 combination that we care most about. Platforms that did not run bench_pictures
66 in the given revision range will not have corresponding outputs. 66 or benchmain in the given revision range will not have corresponding outputs.
67 Please check http://go/skpbench to choose a range that fits your needs. 67 Please check http://go/skpbench to choose a range that fits your needs.
68 BENCH_UB, BENCH_LB and BENCH_ALLOWED_NOISE can be changed to expand or narrow 68 BENCH_UB, BENCH_LB and BENCH_ALLOWED_NOISE can be changed to expand or narrow
69 the permitted bench ranges without triggering buidbot alerts. 69 the permitted bench ranges without triggering buidbot alerts.
70 """ 70 """
71 HELP_STRING = """ 71 HELP_STRING = """
72 Outputs expectation picture bench ranges for the latest revisions for the given 72 Outputs expectation picture bench ranges for the latest revisions for the given
73 revision range. For instance, --rev_range=6000:6000 will return only bench 73 revision range. For instance, --rev_range=6000:6000 will return only bench
74 ranges for the bots that ran bench_pictures at rev 6000; --rev-range=6000:7000 74 ranges for the bots that ran benches at rev 6000; --rev-range=6000:7000
75 may have multiple bench data points for each bench configuration, and the code 75 may have multiple bench data points for each bench configuration, and the code
76 returns bench data for the latest revision of all available (closer to 7000). 76 returns bench data for the latest revision of all available (closer to 7000).
77 """ + HOWTO_STRING 77 """ + HOWTO_STRING
78 78
79 OPTION_REVISION_RANGE = '--rev-range' 79 OPTION_REVISION_RANGE = '--rev-range'
80 OPTION_REVISION_RANGE_SHORT = '-r' 80 OPTION_REVISION_RANGE_SHORT = '-r'
81 # Bench bench representation algorithm flag. 81 # Bench representation algorithm flag.
82 OPTION_REPRESENTATION_ALG = '--algorithm' 82 OPTION_REPRESENTATION_ALG = '--algorithm'
83 OPTION_REPRESENTATION_ALG_SHORT = '-a' 83 OPTION_REPRESENTATION_ALG_SHORT = '-a'
84 # Bench type to examine. Either 'micro' or 'skp'.
85 OPTION_BENCH_TYPE = '--bench-type'
86 OPTION_BENCH_TYPE_SHORT = '-b'
84 87
88 # List of valid bench types.
89 BENCH_TYPES = ['micro', 'skp']
85 # List of valid representation algorithms. 90 # List of valid representation algorithms.
86 REPRESENTATION_ALGS = ['avg', 'min', 'med', '25th'] 91 REPRESENTATION_ALGS = ['avg', 'min', 'med', '25th']
87 92
88 def OutputSkpBenchExpectations(rev_min, rev_max, representation_alg): 93 def OutputBenchExpectations(bench_type, rev_min, rev_max, representation_alg):
89 """Reads skp bench data from google storage, and outputs expectations. 94 """Reads bench data from google storage, and outputs expectations.
90 95
91 Ignores data with revisions outside [rev_min, rev_max] integer range. For 96 Ignores data with revisions outside [rev_min, rev_max] integer range. For
92 bench data with multiple revisions, we use higher revisions to calculate 97 bench data with multiple revisions, we use higher revisions to calculate
93 expected bench values. 98 expected bench values.
99 bench_type is either 'micro' or 'skp', according to the flag '-b'.
94 Uses the provided representation_alg for calculating bench representations. 100 Uses the provided representation_alg for calculating bench representations.
95 """ 101 """
102 if bench_type not in BENCH_TYPES:
103 raise Exception('Not valid bench_type! (%s)' % BENCH_TYPES)
96 expectation_dic = {} 104 expectation_dic = {}
97 uri = boto.storage_uri(URI_BUCKET, GOOGLE_STORAGE_URI_SCHEME) 105 uri = boto.storage_uri(URI_BUCKET, GOOGLE_STORAGE_URI_SCHEME)
98 for obj in uri.get_bucket(): 106 for obj in uri.get_bucket():
99 # Filters out non-skp-bench files. 107 # Filters out non-bench files.
100 if ((not obj.name.startswith('perfdata/%s' % BENCH_BUILDER_PREFIX) and 108 if ((not obj.name.startswith('perfdata/%s' % BENCH_BUILDER_PREFIX) and
101 not obj.name.startswith( 109 not obj.name.startswith(
102 'playback/perfdata/%s' % BENCH_BUILDER_PREFIX)) or 110 'playback/perfdata/%s' % BENCH_BUILDER_PREFIX)) or
103 obj.name.find('_data_skp_') < 0): 111 obj.name.find('_data') < 0):
112 continue
113 if ((bench_type == 'micro' and obj.name.find('_data_skp_') > 0) or
114 (bench_type == 'skp' and obj.name.find('_skp_') < 0)):
115 # Skips wrong bench type.
104 continue 116 continue
105 # Ignores uninterested platforms. 117 # Ignores uninterested platforms.
106 platform = obj.name.split('/')[1] 118 platform = obj.name.split('/')[1]
107 if not platform.startswith(BENCH_BUILDER_PREFIX): 119 if not platform.startswith(BENCH_BUILDER_PREFIX):
108 platform = obj.name.split('/')[2] 120 platform = obj.name.split('/')[2]
109 if not platform.startswith(BENCH_BUILDER_PREFIX): 121 if not platform.startswith(BENCH_BUILDER_PREFIX):
110 continue # Ignores non-platform object 122 continue # Ignores non-platform object
111 if platform not in PLATFORMS: 123 if platform not in PLATFORMS:
112 continue 124 continue
113 # Filters by revision. 125 # Filters by revision.
(...skipping 19 matching lines...) Expand all
133 keys = expectation_dic.keys() 145 keys = expectation_dic.keys()
134 keys.sort() 146 keys.sort()
135 for key in keys: 147 for key in keys:
136 bench_val = expectation_dic[key] 148 bench_val = expectation_dic[key]
137 # Prints out expectation lines. 149 # Prints out expectation lines.
138 print '%s,%.3f,%.3f,%.3f' % (key, bench_val, 150 print '%s,%.3f,%.3f,%.3f' % (key, bench_val,
139 bench_val * BENCH_LB - BENCH_ALLOWED_NOISE, 151 bench_val * BENCH_LB - BENCH_ALLOWED_NOISE,
140 bench_val * BENCH_UB + BENCH_ALLOWED_NOISE) 152 bench_val * BENCH_UB + BENCH_ALLOWED_NOISE)
141 153
142 def main(): 154 def main():
143 """Parses flags and outputs expected Skia picture bench results.""" 155 """Parses flags and outputs expected Skia bench results."""
144 parser = optparse.OptionParser(USAGE_STRING % '%prog' + HELP_STRING) 156 parser = optparse.OptionParser(USAGE_STRING % '%prog' + HELP_STRING)
145 parser.add_option(OPTION_REVISION_RANGE_SHORT, OPTION_REVISION_RANGE, 157 parser.add_option(OPTION_REVISION_RANGE_SHORT, OPTION_REVISION_RANGE,
146 dest='rev_range', 158 dest='rev_range',
147 help='(Mandatory) revision range separated by ":", e.g., 6000:6005') 159 help='(Mandatory) revision range separated by ":", e.g., 6000:6005')
160 parser.add_option(OPTION_BENCH_TYPE_SHORT, OPTION_BENCH_TYPE,
161 dest='bench_type', default='skp',
162 help=('Bench type, either "skp" or "micro". Default to "skp".'))
148 parser.add_option(OPTION_REPRESENTATION_ALG_SHORT, OPTION_REPRESENTATION_ALG, 163 parser.add_option(OPTION_REPRESENTATION_ALG_SHORT, OPTION_REPRESENTATION_ALG,
149 dest='alg', default='25th', 164 dest='alg', default='25th',
150 help=('Bench representation algorithm. One of ' 165 help=('Bench representation algorithm. One of '
151 '%s. Default to "25th".' % str(REPRESENTATION_ALGS))) 166 '%s. Default to "25th".' % str(REPRESENTATION_ALGS)))
152 (options, args) = parser.parse_args() 167 (options, args) = parser.parse_args()
153 if options.rev_range: 168 if options.rev_range:
154 range_match = re.search('(\d+)\:(\d+)', options.rev_range) 169 range_match = re.search('(\d+)\:(\d+)', options.rev_range)
155 if not range_match: 170 if not range_match:
156 parser.error('Wrong format for rev-range [%s]' % options.rev_range) 171 parser.error('Wrong format for rev-range [%s]' % options.rev_range)
157 else: 172 else:
158 rev_min = int(range_match.group(1)) 173 rev_min = int(range_match.group(1))
159 rev_max = int(range_match.group(2)) 174 rev_max = int(range_match.group(2))
160 OutputSkpBenchExpectations(rev_min, rev_max, options.alg) 175 OutputBenchExpectations(options.bench_type, rev_min, rev_max, options.alg)
161 else: 176 else:
162 parser.error('Please provide mandatory flag %s' % OPTION_REVISION_RANGE) 177 parser.error('Please provide mandatory flag %s' % OPTION_REVISION_RANGE)
163 178
164 179
165 if '__main__' == __name__: 180 if '__main__' == __name__:
166 main() 181 main()
OLDNEW
« no previous file with comments | « no previous file | bench/gen_skp_ranges.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698