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

Side by Side Diff: mojo/devtools/common/mojo_benchmark

Issue 1414353006: Define measurements as a tuple of name and spec. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 1 month 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 | mojo/tools/data/benchmarks » ('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 2015 The Chromium Authors. All rights reserved. 2 # Copyright 2015 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 """Runner for Mojo application benchmarks.""" 6 """Runner for Mojo application benchmarks."""
7 7
8 import argparse 8 import argparse
9 import json 9 import json
10 import logging 10 import logging
(...skipping 13 matching lines...) Expand all
24 global variable, containing entries of the following form: 24 global variable, containing entries of the following form:
25 25
26 { 26 {
27 'name': '<name of the benchmark>', 27 'name': '<name of the benchmark>',
28 'app': '<url of the app to benchmark>', 28 'app': '<url of the app to benchmark>',
29 'shell-args': [], 29 'shell-args': [],
30 'duration': <duration in seconds>, 30 'duration': <duration in seconds>,
31 31
32 # List of measurements to make. 32 # List of measurements to make.
33 'measurements': [ 33 'measurements': [
34 '<measurement type>/<event category>/<event name>', 34 {
35 'name': my_measurement,
36 'spec': spec,
37 },
38 (...)
35 ] 39 ]
36 } 40 }
37 41
42 For each measurement, 'name' is a label used for presentation purposes. 'spec'
43 defines the measurement.
44
38 Available measurement types are: 45 Available measurement types are:
39 46
40 - 'time_until' - time until the first occurence of the targeted event 47 'time_until' - time until the first occurence of the targeted event. The spec
41 - 'avg_duration' - average duration of the targeted event 48 takes the following format:
42 - 'percentile_duration' - value at XXth percentile of the targeted event where 49
43 XX is from the measurement spec, i.e. .../<event name>/0.XX 50 'time_until/category/event'
51
52 'avg_duration' - average duration of the targeted event. The spec takes the
53 following format:
54
55 'avg_duration/category/event'
56
57 'percentile_duration' - value at the given percentile of the targeted event. The
58 spec takes the following format:
59
60 'percentile_duration/category/event/percentile'
44 61
45 |benchmark_list_file| may reference the |target_os| global that will be any of 62 |benchmark_list_file| may reference the |target_os| global that will be any of
46 ['android', 'linux'], indicating the system on which the benchmarks are to be 63 ['android', 'linux'], indicating the system on which the benchmarks are to be
47 run. 64 run.
48 """ 65 """
49 66
50 _logger = logging.getLogger() 67 _logger = logging.getLogger()
51 68
52 _BENCHMARK_APP = 'https://core.mojoapps.io/benchmark.mojo' 69 _BENCHMARK_APP = 'https://core.mojoapps.io/benchmark.mojo'
53 _CACHE_SERVICE_URL = 'mojo:url_response_disk_cache' 70 _CACHE_SERVICE_URL = 'mojo:url_response_disk_cache'
54 _NETWORK_SERVICE_URL = 'mojo:network_service' 71 _NETWORK_SERVICE_URL = 'mojo:network_service'
55 72
56 _COLD_START_SHELL_ARGS = [ 73 _COLD_START_SHELL_ARGS = [
57 '--args-for=%s %s' % (_CACHE_SERVICE_URL, '--clear'), 74 '--args-for=%s %s' % (_CACHE_SERVICE_URL, '--clear'),
58 '--args-for=%s %s' % (_NETWORK_SERVICE_URL, '--clear'), 75 '--args-for=%s %s' % (_NETWORK_SERVICE_URL, '--clear'),
59 ] 76 ]
60 77
61 # Additional time in seconds allocated per shell run to accommodate start-up. 78 # Additional time in seconds allocated per shell run to accommodate start-up.
62 # The shell should terminate before hitting this time out, it is an error if it 79 # The shell should terminate before hitting this time out, it is an error if it
63 # doesn't. 80 # doesn't.
64 _EXTRA_TIMEOUT = 20 81 _EXTRA_TIMEOUT = 20
65 82
66 _MEASUREMENT_RESULT_FORMAT = r""" 83 _MEASUREMENT_RESULT_FORMAT = r"""
67 ^ # Beginning of the line. 84 ^ # Beginning of the line.
68 measurement: # Hard-coded tag. 85 measurement: # Hard-coded tag.
69 \s+(\S+) # Match measurement name. 86 \s+(\S+) # Match measurement spec.
70 \s+(\S+) # Match measurement result. 87 \s+(\S+) # Match measurement result.
71 $ # End of the line. 88 $ # End of the line.
72 """ 89 """
73 90
74 _MEASUREMENT_REGEX = re.compile(_MEASUREMENT_RESULT_FORMAT, re.VERBOSE) 91 _MEASUREMENT_REGEX = re.compile(_MEASUREMENT_RESULT_FORMAT, re.VERBOSE)
75 92
76 93
77 def _generate_benchmark_variants(benchmark_spec): 94 def _generate_benchmark_variants(benchmark_spec):
78 """Generates benchmark specifications for individual variants of the given 95 """Generates benchmark specifications for individual variants of the given
79 benchmark: cold start and warm start. 96 benchmark: cold start and warm start.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 131
115 device_output_file = None 132 device_output_file = None
116 if output_file: 133 if output_file:
117 if android: 134 if android:
118 device_output_file = os.path.join(shell.get_tmp_dir_path(), output_file) 135 device_output_file = os.path.join(shell.get_tmp_dir_path(), output_file)
119 benchmark_args.append('--trace-output=' + device_output_file) 136 benchmark_args.append('--trace-output=' + device_output_file)
120 else: 137 else:
121 benchmark_args.append('--trace-output=' + output_file) 138 benchmark_args.append('--trace-output=' + output_file)
122 139
123 for measurement in measurements: 140 for measurement in measurements:
124 benchmark_args.append(measurement) 141 benchmark_args.append(measurement['spec'])
125 142
126 shell_args = list(shell_args) 143 shell_args = list(shell_args)
127 shell_args.append(_BENCHMARK_APP) 144 shell_args.append(_BENCHMARK_APP)
128 shell_args.append('--force-offline-by-default') 145 shell_args.append('--force-offline-by-default')
129 shell_args.append('--args-for=%s %s' % (_BENCHMARK_APP, 146 shell_args.append('--args-for=%s %s' % (_BENCHMARK_APP,
130 ' '.join(benchmark_args))) 147 ' '.join(benchmark_args)))
131 148
132 if verbose: 149 if verbose:
133 print 'shell arguments: ' + str(shell_args) 150 print 'shell arguments: ' + str(shell_args)
134 return_code, output, did_time_out = shell.run_and_get_output( 151 return_code, output, did_time_out = shell.run_and_get_output(
(...skipping 13 matching lines...) Expand all
148 165
149 def _parse_measurement_results(output): 166 def _parse_measurement_results(output):
150 """Parses the measurement results present in the benchmark output and returns 167 """Parses the measurement results present in the benchmark output and returns
151 the dictionary of correctly recognized and parsed results. 168 the dictionary of correctly recognized and parsed results.
152 """ 169 """
153 measurement_results = {} 170 measurement_results = {}
154 output_lines = [line.strip() for line in output.split('\n')] 171 output_lines = [line.strip() for line in output.split('\n')]
155 for line in output_lines: 172 for line in output_lines:
156 match = re.match(_MEASUREMENT_REGEX, line) 173 match = re.match(_MEASUREMENT_REGEX, line)
157 if match: 174 if match:
158 measurement_name = match.group(1) 175 measurement_spec = match.group(1)
159 measurement_result = match.group(2) 176 measurement_result = match.group(2)
160 try: 177 try:
161 measurement_results[measurement_name] = float(measurement_result) 178 measurement_results[measurement_spec] = float(measurement_result)
162 except ValueError: 179 except ValueError:
163 pass 180 pass
164 return measurement_results 181 return measurement_results
165 182
166 183
167 def main(): 184 def main():
168 parser = argparse.ArgumentParser( 185 parser = argparse.ArgumentParser(
169 formatter_class=argparse.RawDescriptionHelpFormatter, 186 formatter_class=argparse.RawDescriptionHelpFormatter,
170 description=_DESCRIPTION) 187 description=_DESCRIPTION)
171 parser.add_argument('benchmark_list_file', type=file, 188 parser.add_argument('benchmark_list_file', type=file,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 shell, shell_args, variant_name, app, duration, measurements, 233 shell, shell_args, variant_name, app, duration, measurements,
217 script_args.verbose, script_args.android, output_file) 234 script_args.verbose, script_args.android, output_file)
218 235
219 print '[ %s ] %s ' % (benchmark_name, variant_name) 236 print '[ %s ] %s ' % (benchmark_name, variant_name)
220 237
221 some_measurements_failed = False 238 some_measurements_failed = False
222 if benchmark_succeeded: 239 if benchmark_succeeded:
223 measurement_results = _parse_measurement_results(output) 240 measurement_results = _parse_measurement_results(output)
224 # Iterate over the list of specs, not the dictionary, to detect missing 241 # Iterate over the list of specs, not the dictionary, to detect missing
225 # results and preserve the required order. 242 # results and preserve the required order.
226 for measurement_spec in measurements: 243 for measurement in measurements:
227 if measurement_spec in measurement_results: 244 if measurement['spec'] in measurement_results:
228 result = measurement_results[measurement_spec] 245 result = measurement_results[measurement['spec']]
229 print '%s %s' % (measurement_spec, result) 246 print '%10.4f %s' % (result, measurement['name'])
230 247
231 if chart_data_recorder: 248 if chart_data_recorder:
232 chart_name = benchmark_name + '__' + variant_name 249 chart_name = benchmark_name + '__' + variant_name
233 chart_data_recorder.record_scalar( 250 chart_data_recorder.record_scalar(
234 perf_dashboard.normalize_label(chart_name), 251 perf_dashboard.normalize_label(chart_name),
235 perf_dashboard.normalize_label(measurement_spec), 252 perf_dashboard.normalize_label(measurement['name']),
236 'ms', result) 253 'ms', result)
237 else: 254 else:
238 print '%s ?' % measurement_spec 255 print '? %s' % measurement['name']
239 some_measurements_failed = True 256 some_measurements_failed = True
240 257
241 if not benchmark_succeeded or some_measurements_failed: 258 if not benchmark_succeeded or some_measurements_failed:
242 if not benchmark_succeeded: 259 if not benchmark_succeeded:
243 print 'benchmark failed: ' + benchmark_error 260 print 'benchmark failed: ' + benchmark_error
244 if some_measurements_failed: 261 if some_measurements_failed:
245 print 'some measurements failed' 262 print 'some measurements failed'
246 print 'output: ' 263 print 'output: '
247 print '-' * 72 264 print '-' * 72
248 print output 265 print output
249 print '-' * 72 266 print '-' * 72
250 exit_code = 1 267 exit_code = 1
251 268
252 if script_args.upload: 269 if script_args.upload:
253 perf_dashboard.upload_chart_data( 270 perf_dashboard.upload_chart_data(
254 script_args.master_name, script_args.bot_name, 271 script_args.master_name, script_args.bot_name,
255 script_args.test_name, script_args.builder_name, 272 script_args.test_name, script_args.builder_name,
256 script_args.build_number, chart_data_recorder.get_chart_data(), 273 script_args.build_number, chart_data_recorder.get_chart_data(),
257 script_args.server_url, script_args.dry_run) 274 script_args.server_url, script_args.dry_run)
258 275
259 return exit_code 276 return exit_code
260 277
261 if __name__ == '__main__': 278 if __name__ == '__main__':
262 sys.exit(main()) 279 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | mojo/tools/data/benchmarks » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698