Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 measure.') | |
|
pasko
2016/04/28 15:04:59
Enable optional measurements.
gabadie
2016/04/28 15:56:22
Done.
| |
| 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 Loading... | |
| 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 |
| 297 def BenchmarkRunnerTransformer(runner): | |
| 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 | |
|
gabadie
2016/04/28 14:29:32
Passing down these benchmark specific parameters u
| |
| 301 | |
| 292 runner_transformer_name = 'no-network-emulation' | 302 runner_transformer_name = 'no-network-emulation' |
| 293 runner_transformer = lambda arg: None | 303 runner_transformer = BenchmarkRunnerTransformer |
| 294 builder.PopulateLoadBenchmark(sandwich_misc.EMPTY_CACHE_DISCOVERER, | 304 builder.PopulateLoadBenchmark(sandwich_misc.EMPTY_CACHE_DISCOVERER, |
| 295 runner_transformer_name, runner_transformer) | 305 runner_transformer_name, runner_transformer) |
| 296 builder.PopulateLoadBenchmark(sandwich_misc.FULL_CACHE_DISCOVERER, | 306 builder.PopulateLoadBenchmark(sandwich_misc.FULL_CACHE_DISCOVERER, |
| 297 runner_transformer_name, runner_transformer) | 307 runner_transformer_name, runner_transformer) |
| 298 | 308 |
| 299 if args.gen_full: | 309 if args.gen_full: |
| 300 for subresource_discoverer in sandwich_misc.SUBRESOURCE_DISCOVERERS: | 310 for subresource_discoverer in sandwich_misc.SUBRESOURCE_DISCOVERERS: |
| 301 if subresource_discoverer == sandwich_misc.FULL_CACHE_DISCOVERER: | 311 if subresource_discoverer == sandwich_misc.FULL_CACHE_DISCOVERER: |
| 302 continue | 312 continue |
| 303 for network_condition in ['Regular4G', 'Regular3G', 'Regular2G']: | 313 for network_condition in ['Regular4G', 'Regular3G', 'Regular2G']: |
| 304 runner_transformer_name = network_condition.lower() | 314 runner_transformer_name = network_condition.lower() |
| 305 runner_transformer = sandwich_task_builder.NetworkSimulationTransformer( | 315 runner_transformer = sandwich_task_builder.NetworkSimulationTransformer( |
| 306 network_condition) | 316 network_condition, parent_transformer=BenchmarkRunnerTransformer) |
| 307 builder.PopulateLoadBenchmark( | 317 builder.PopulateLoadBenchmark( |
| 308 subresource_discoverer, runner_transformer_name, runner_transformer) | 318 subresource_discoverer, runner_transformer_name, runner_transformer) |
| 309 | 319 |
| 310 return task_manager.ExecuteWithCommandLine( | 320 return task_manager.ExecuteWithCommandLine( |
| 311 args, builder.tasks.values(), builder.default_final_tasks) | 321 args, builder.tasks.values(), builder.default_final_tasks) |
| 312 | 322 |
| 313 | 323 |
| 314 def main(command_line_args): | 324 def main(command_line_args): |
| 315 logging.basicConfig(level=logging.INFO) | 325 logging.basicConfig(level=logging.INFO) |
| 316 devil_chromium.Initialize() | 326 devil_chromium.Initialize() |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 333 return _FilterCacheMain(args) | 343 return _FilterCacheMain(args) |
| 334 if args.subcommand == 'record-test-trace': | 344 if args.subcommand == 'record-test-trace': |
| 335 return _RecordWebServerTestTrace(args) | 345 return _RecordWebServerTestTrace(args) |
| 336 if args.subcommand == 'run-all': | 346 if args.subcommand == 'run-all': |
| 337 return _RunAllMain(args) | 347 return _RunAllMain(args) |
| 338 assert False | 348 assert False |
| 339 | 349 |
| 340 | 350 |
| 341 if __name__ == '__main__': | 351 if __name__ == '__main__': |
| 342 sys.exit(main(sys.argv[1:])) | 352 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |