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

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

Issue 1872313002: sandwich: Implement SandwichTaskBuilder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
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 17 matching lines...) Expand all
28 from pylib import constants 28 from pylib import constants
29 import devil_chromium 29 import devil_chromium
30 30
31 import chrome_cache 31 import chrome_cache
32 import common_util 32 import common_util
33 import emulation 33 import emulation
34 import options 34 import options
35 import sandwich_metrics 35 import sandwich_metrics
36 import sandwich_misc 36 import sandwich_misc
37 from sandwich_runner import SandwichRunner 37 from sandwich_runner import SandwichRunner
38 import sandwich_tasks
39 import task_manager
38 from trace_test.webserver_test import WebServer 40 from trace_test.webserver_test import WebServer
39 41
40 42
41 # Use options layer to access constants. 43 # Use options layer to access constants.
42 OPTIONS = options.OPTIONS 44 OPTIONS = options.OPTIONS
43 45
44 46
45 def _ArgumentParser(): 47 def _ArgumentParser():
46 """Build a command line argument's parser.""" 48 """Build a command line argument's parser."""
47 # Command parser when dealing with jobs. 49 # Command parser when dealing with jobs.
48 common_job_parser = argparse.ArgumentParser(add_help=False) 50 common_job_parser = argparse.ArgumentParser(add_help=False)
49 common_job_parser.add_argument('--job', required=True, 51 common_job_parser.add_argument('--job', required=True,
50 help='JSON file with job description.') 52 help='JSON file with job description.')
51 53
54 orchestra_parser = task_manager.CommandLineParser()
55
52 # Plumbing parser to configure OPTIONS. 56 # Plumbing parser to configure OPTIONS.
53 plumbing_parser = OPTIONS.GetParentParser('plumbing options') 57 plumbing_parser = OPTIONS.GetParentParser('plumbing options')
54 58
55 # Main parser 59 # Main parser
56 parser = argparse.ArgumentParser(parents=[plumbing_parser]) 60 parser = argparse.ArgumentParser(parents=[plumbing_parser])
57 subparsers = parser.add_subparsers(dest='subcommand', help='subcommand line') 61 subparsers = parser.add_subparsers(dest='subcommand', help='subcommand line')
58 62
59 # Record WPR subcommand. 63 # Record WPR subcommand.
60 record_wpr = subparsers.add_parser('record-wpr', parents=[common_job_parser], 64 record_wpr = subparsers.add_parser('record-wpr', parents=[common_job_parser],
61 help='Record WPR from sandwich job.') 65 help='Record WPR from sandwich job.')
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 help='Record a test trace using the trace_test.webserver_test.') 163 help='Record a test trace using the trace_test.webserver_test.')
160 record_trace_parser.add_argument('--source-dir', type=str, required=True, 164 record_trace_parser.add_argument('--source-dir', type=str, required=True,
161 help='Base path where the files are opened' 165 help='Base path where the files are opened'
162 'by the web server.') 166 'by the web server.')
163 record_trace_parser.add_argument('--page', type=str, required=True, 167 record_trace_parser.add_argument('--page', type=str, required=True,
164 help='Source page in source-dir to navigate ' 168 help='Source page in source-dir to navigate '
165 'to.') 169 'to.')
166 record_trace_parser.add_argument('-o', '--output', type=str, required=True, 170 record_trace_parser.add_argument('-o', '--output', type=str, required=True,
167 help='Output path of the generated trace.') 171 help='Output path of the generated trace.')
168 172
173 # Run all subcommand.
174 run_all = subparsers.add_parser('run-all',
175 parents=[common_job_parser, orchestra_parser],
176 help='Run the sandwich orchestra.')
pasko 2016/04/11 14:54:08 'Run all steps using the task manager infrastructu
gabadie 2016/04/13 09:53:44 Done.
177 run_all.add_argument('-g', '--gen-full', action='store_true',
178 help='Generate the full orchestra.')
pasko 2016/04/11 14:54:08 there is no more orchestra. For now we can say: 'G
gabadie 2016/04/13 09:53:44 Done.
179 run_all.add_argument('--wpr-archive', default=None, type=str,
180 dest='wpr_archive_path',
181 help='Web page replay archive to load job\'s urls '
pasko 2016/04/11 14:54:08 help='WebPageReplay archive to use, instead of gen
gabadie 2016/04/13 09:53:44 Done.
182 'from.')
183 run_all.add_argument('--url-repeat', default=1, type=int,
184 help='How many times to repeat the urls.')
185
169 return parser 186 return parser
170 187
171 188
172 def _RecordWprMain(args): 189 def _RecordWprMain(args):
173 sandwich_runner = SandwichRunner() 190 sandwich_runner = SandwichRunner()
174 sandwich_runner.LoadJob(args.job) 191 sandwich_runner.LoadJob(args.job)
175 sandwich_runner.PullConfigFromArgs(args) 192 sandwich_runner.PullConfigFromArgs(args)
176 sandwich_runner.wpr_record = True 193 sandwich_runner.wpr_record = True
177 sandwich_runner.PrintConfig() 194 sandwich_runner.PrintConfig()
178 if not os.path.isdir(os.path.dirname(args.wpr_archive_path)): 195 if not os.path.isdir(os.path.dirname(args.wpr_archive_path)):
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 sandwich_runner.trace_output_directory = os.path.join(out_path, 'run') 254 sandwich_runner.trace_output_directory = os.path.join(out_path, 'run')
238 with WebServer.Context( 255 with WebServer.Context(
239 source_dir=args.source_dir, communication_dir=out_path) as server: 256 source_dir=args.source_dir, communication_dir=out_path) as server:
240 address = server.Address() 257 address = server.Address()
241 sandwich_runner.urls = ['http://%s/%s' % (address, args.page)] 258 sandwich_runner.urls = ['http://%s/%s' % (address, args.page)]
242 sandwich_runner.Run() 259 sandwich_runner.Run()
243 shutil.copy(os.path.join(out_path, 'run', '0', 'trace.json'), args.output) 260 shutil.copy(os.path.join(out_path, 'run', '0', 'trace.json'), args.output)
244 return 0 261 return 0
245 262
246 263
264 def _RunAllMain(args):
265 runner_modifiers = {
266 '2g': sandwich_tasks.EmulateNetworkModifier('Regular2G'),
pasko 2016/04/11 14:54:08 Let's rename it to something like NetworkSimulatio
gabadie 2016/04/13 09:53:44 Done.
267 '3g': sandwich_tasks.EmulateNetworkModifier('Regular3G'),
268 '4g': sandwich_tasks.EmulateNetworkModifier('Regular4G')
269 }
270
271 builder = sandwich_tasks.SandwichTaskBuilder(
272 output_directory=args.output,
273 job_path=args.job,
274 url_repeat=args.url_repeat)
275 if args.wpr_archive_path:
276 builder.SetOriginalWprPath(args.wpr_archive_path)
277 else:
278 builder.PopulateWPRRecordingTask()
279 builder.PopulateCommonPipelines()
280 builder.PopulateFullCacheLoadBenchmark()
281 builder.PopulateClearCacheLoadBenchmark()
282 builder.PopulateNoStatePrefetchLoadBenchmark()
283
284 if args.gen_full:
285 for key, runner_modifier in runner_modifiers.iteritems():
286 builder.PopulateClearCacheLoadBenchmark(
287 benchmark_name='clearcache-' + key,
288 runner_modifier=runner_modifier)
289 builder.PopulateNoStatePrefetchLoadBenchmark(
290 benchmark_name='prefetch-' + key,
291 runner_modifier=runner_modifier)
292
293 return task_manager.ExecuteWithCommandLine(
294 args, builder.tasks.values(), builder.default_final_tasks)
295
296
247 def main(command_line_args): 297 def main(command_line_args):
248 logging.basicConfig(level=logging.INFO) 298 logging.basicConfig(level=logging.INFO)
249 devil_chromium.Initialize() 299 devil_chromium.Initialize()
250 300
251 args = _ArgumentParser().parse_args(command_line_args) 301 args = _ArgumentParser().parse_args(command_line_args)
252 OPTIONS.SetParsedArgs(args) 302 OPTIONS.SetParsedArgs(args)
253 303
254 if args.subcommand == 'record-wpr': 304 if args.subcommand == 'record-wpr':
255 return _RecordWprMain(args) 305 return _RecordWprMain(args)
256 if args.subcommand == 'patch-wpr': 306 if args.subcommand == 'patch-wpr':
257 sandwich_misc.PatchWpr(args.wpr_archive_path) 307 sandwich_misc.PatchWpr(args.wpr_archive_path)
258 return 0 308 return 0
259 if args.subcommand == 'create-cache': 309 if args.subcommand == 'create-cache':
260 return _CreateCacheMain(args) 310 return _CreateCacheMain(args)
261 if args.subcommand == 'run': 311 if args.subcommand == 'run':
262 return _RunJobMain(args) 312 return _RunJobMain(args)
263 if args.subcommand == 'extract-metrics': 313 if args.subcommand == 'extract-metrics':
264 return _ExtractMetricsMain(args) 314 return _ExtractMetricsMain(args)
265 if args.subcommand == 'filter-cache': 315 if args.subcommand == 'filter-cache':
266 return _FilterCacheMain(args) 316 return _FilterCacheMain(args)
267 if args.subcommand == 'record-test-trace': 317 if args.subcommand == 'record-test-trace':
268 return _RecordWebServerTestTrace(args) 318 return _RecordWebServerTestTrace(args)
319 if args.subcommand == 'run-all':
320 return _RunAllMain(args)
269 assert False 321 assert False
270 322
271 323
272 if __name__ == '__main__': 324 if __name__ == '__main__':
273 sys.exit(main(sys.argv[1:])) 325 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | tools/android/loading/sandwich_misc.py » ('j') | tools/android/loading/sandwich_tasks.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698