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

Side by Side Diff: tools/android/loading/sandwich.py

Issue 1925803003: sandwich: Make speed-index and memory measurement optional from run-all (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addresses Egor's nit Created 4 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 | tools/android/loading/sandwich_metrics.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 2016 The Chromium Authors. All rights reserved. 2 # Copyright 2016 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 """Instructs Chrome to load series of web pages and reports results. 6 """Instructs Chrome to load series of web pages and reports results.
7 7
8 When running Chrome is sandwiched between preprocessed disk caches and 8 When running Chrome is sandwiched between preprocessed disk caches and
9 WepPageReplay serving all connections. 9 WepPageReplay serving all connections.
10 10
(...skipping 26 matching lines...) Expand all
37 import sandwich_misc 37 import sandwich_misc
38 from sandwich_runner import SandwichRunner 38 from sandwich_runner import SandwichRunner
39 import sandwich_task_builder 39 import sandwich_task_builder
40 import task_manager 40 import task_manager
41 from trace_test.webserver_test import WebServer 41 from trace_test.webserver_test import WebServer
42 42
43 43
44 # Use options layer to access constants. 44 # Use options layer to access constants.
45 OPTIONS = options.OPTIONS 45 OPTIONS = options.OPTIONS
46 46
47 _SPEED_INDEX_MEASUREMENT = 'speed-index'
48 _MEMORY_MEASUREMENT = 'memory'
49
47 50
48 def _ArgumentParser(): 51 def _ArgumentParser():
49 """Build a command line argument's parser.""" 52 """Build a command line argument's parser."""
50 # Command parser when dealing with jobs. 53 # Command parser when dealing with jobs.
51 common_job_parser = argparse.ArgumentParser(add_help=False) 54 common_job_parser = argparse.ArgumentParser(add_help=False)
52 common_job_parser.add_argument('--job', required=True, 55 common_job_parser.add_argument('--job', required=True,
53 help='JSON file with job description.') 56 help='JSON file with job description.')
54 common_job_parser.add_argument('--android', default=None, type=str, 57 common_job_parser.add_argument('--android', default=None, type=str,
55 dest='android_device_serial', 58 dest='android_device_serial',
56 help='Android device\'s serial to use.') 59 help='Android device\'s serial to use.')
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 help='Source page in source-dir to navigate ' 175 help='Source page in source-dir to navigate '
173 'to.') 176 'to.')
174 record_trace_parser.add_argument('-o', '--output', type=str, required=True, 177 record_trace_parser.add_argument('-o', '--output', type=str, required=True,
175 help='Output path of the generated trace.') 178 help='Output path of the generated trace.')
176 179
177 # Run all subcommand. 180 # Run all subcommand.
178 run_all = subparsers.add_parser('run-all', 181 run_all = subparsers.add_parser('run-all',
179 parents=[common_job_parser, task_parser], 182 parents=[common_job_parser, task_parser],
180 help='Run all steps using the task manager ' 183 help='Run all steps using the task manager '
181 'infrastructure.') 184 'infrastructure.')
185 run_all.add_argument('-m', '--measure', default=[], dest='optional_measures',
186 choices=[_SPEED_INDEX_MEASUREMENT, _MEMORY_MEASUREMENT],
187 nargs='+', help='Enable optional measurements.')
182 run_all.add_argument('-g', '--gen-full', action='store_true', 188 run_all.add_argument('-g', '--gen-full', action='store_true',
183 help='Generate the full graph with all possible' 189 help='Generate the full graph with all possible'
184 'benchmarks.') 190 'benchmarks.')
185 run_all.add_argument('--wpr-archive', default=None, type=str, 191 run_all.add_argument('--wpr-archive', default=None, type=str,
186 dest='wpr_archive_path', 192 dest='wpr_archive_path',
187 help='WebPageReplay archive to use, instead of ' 193 help='WebPageReplay archive to use, instead of '
188 'generating one.') 194 'generating one.')
189 run_all.add_argument('--url-repeat', default=1, type=int, 195 run_all.add_argument('--url-repeat', default=1, type=int,
190 help='How many times to repeat the urls.') 196 help='How many times to repeat the urls.')
191 197
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 280
275 281
276 def _RunAllMain(args): 282 def _RunAllMain(args):
277 android_device = None 283 android_device = None
278 if args.android_device_serial: 284 if args.android_device_serial:
279 android_device = \ 285 android_device = \
280 device_setup.GetDeviceFromSerial(args.android_device_serial) 286 device_setup.GetDeviceFromSerial(args.android_device_serial)
281 builder = sandwich_task_builder.SandwichTaskBuilder( 287 builder = sandwich_task_builder.SandwichTaskBuilder(
282 output_directory=args.output, 288 output_directory=args.output,
283 android_device=android_device, 289 android_device=android_device,
284 job_path=args.job, 290 job_path=args.job)
285 url_repeat=args.url_repeat)
286 if args.wpr_archive_path: 291 if args.wpr_archive_path:
287 builder.OverridePathToWprArchive(args.wpr_archive_path) 292 builder.OverridePathToWprArchive(args.wpr_archive_path)
288 else: 293 else:
289 builder.PopulateWprRecordingTask() 294 builder.PopulateWprRecordingTask()
290 builder.PopulateCommonPipelines() 295 builder.PopulateCommonPipelines()
291 296
292 runner_transformer_name = 'no-network-emulation' 297 def MainTransformer(runner):
293 runner_transformer = lambda arg: None 298 runner.record_video = _SPEED_INDEX_MEASUREMENT in args.optional_measures
299 runner.record_memory_dumps = _MEMORY_MEASUREMENT in args.optional_measures
300 runner.job_repeat = args.url_repeat
301
302 transformer_list_name = 'no-network-emulation'
294 builder.PopulateLoadBenchmark(sandwich_misc.EMPTY_CACHE_DISCOVERER, 303 builder.PopulateLoadBenchmark(sandwich_misc.EMPTY_CACHE_DISCOVERER,
295 runner_transformer_name, runner_transformer) 304 transformer_list_name,
305 transformer_list=[MainTransformer])
296 builder.PopulateLoadBenchmark(sandwich_misc.FULL_CACHE_DISCOVERER, 306 builder.PopulateLoadBenchmark(sandwich_misc.FULL_CACHE_DISCOVERER,
297 runner_transformer_name, runner_transformer) 307 transformer_list_name,
308 transformer_list=[MainTransformer])
298 309
299 if args.gen_full: 310 if args.gen_full:
300 for subresource_discoverer in sandwich_misc.SUBRESOURCE_DISCOVERERS: 311 for network_condition in ['Regular4G', 'Regular3G', 'Regular2G']:
301 if subresource_discoverer == sandwich_misc.FULL_CACHE_DISCOVERER: 312 transformer_list_name = network_condition.lower()
302 continue 313 network_transformer = \
303 for network_condition in ['Regular4G', 'Regular3G', 'Regular2G']: 314 sandwich_task_builder.NetworkSimulationTransformer(network_condition)
304 runner_transformer_name = network_condition.lower() 315 transformer_list = [MainTransformer, network_transformer]
305 runner_transformer = sandwich_task_builder.NetworkSimulationTransformer( 316 for subresource_discoverer in sandwich_misc.SUBRESOURCE_DISCOVERERS:
306 network_condition) 317 if subresource_discoverer == sandwich_misc.FULL_CACHE_DISCOVERER:
307 builder.PopulateLoadBenchmark( 318 continue
308 subresource_discoverer, runner_transformer_name, runner_transformer) 319 builder.PopulateLoadBenchmark(subresource_discoverer,
320 transformer_list_name, transformer_list)
309 321
310 return task_manager.ExecuteWithCommandLine( 322 return task_manager.ExecuteWithCommandLine(
311 args, builder.tasks.values(), builder.default_final_tasks) 323 args, builder.tasks.values(), builder.default_final_tasks)
312 324
313 325
314 def main(command_line_args): 326 def main(command_line_args):
315 logging.basicConfig(level=logging.INFO) 327 logging.basicConfig(level=logging.INFO)
316 devil_chromium.Initialize() 328 devil_chromium.Initialize()
317 329
318 args = _ArgumentParser().parse_args(command_line_args) 330 args = _ArgumentParser().parse_args(command_line_args)
(...skipping 14 matching lines...) Expand all
333 return _FilterCacheMain(args) 345 return _FilterCacheMain(args)
334 if args.subcommand == 'record-test-trace': 346 if args.subcommand == 'record-test-trace':
335 return _RecordWebServerTestTrace(args) 347 return _RecordWebServerTestTrace(args)
336 if args.subcommand == 'run-all': 348 if args.subcommand == 'run-all':
337 return _RunAllMain(args) 349 return _RunAllMain(args)
338 assert False 350 assert False
339 351
340 352
341 if __name__ == '__main__': 353 if __name__ == '__main__':
342 sys.exit(main(sys.argv[1:])) 354 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | tools/android/loading/sandwich_metrics.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698