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

Side by Side Diff: tools/skp/webpages_playback.py

Issue 1066933006: Add ability to specify extra browser args and a prefix for SKP names to webpages_playback.py (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Created 5 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
« no previous file with comments | « no previous file | no next file » | 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 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 """Archives or replays webpages and creates SKPs in a Google Storage location. 6 """Archives or replays webpages and creates SKPs in a Google Storage location.
7 7
8 To archive webpages and store SKP files (archives should be rarely updated): 8 To archive webpages and store SKP files (archives should be rarely updated):
9 9
10 cd skia 10 cd skia
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 return s 131 return s
132 132
133 133
134 class SkPicturePlayback(object): 134 class SkPicturePlayback(object):
135 """Class that archives or replays webpages and creates SKPs.""" 135 """Class that archives or replays webpages and creates SKPs."""
136 136
137 def __init__(self, parse_options): 137 def __init__(self, parse_options):
138 """Constructs a SkPicturePlayback BuildStep instance.""" 138 """Constructs a SkPicturePlayback BuildStep instance."""
139 assert parse_options.browser_executable, 'Must specify --browser_executable' 139 assert parse_options.browser_executable, 'Must specify --browser_executable'
140 self._browser_executable = parse_options.browser_executable 140 self._browser_executable = parse_options.browser_executable
141 self._browser_args = '--disable-setuid-sandbox'
142 if parse_options.browser_extra_args:
143 self._browser_args = '%s %s' % (
144 self._browser_args, parse_options.browser_extra_args)
141 145
142 self._chrome_page_sets_path = os.path.join(parse_options.chrome_src_path, 146 self._chrome_page_sets_path = os.path.join(parse_options.chrome_src_path,
143 CHROMIUM_PAGE_SETS_PATH) 147 CHROMIUM_PAGE_SETS_PATH)
144 self._all_page_sets_specified = parse_options.page_sets == 'all' 148 self._all_page_sets_specified = parse_options.page_sets == 'all'
145 self._page_sets = self._ParsePageSets(parse_options.page_sets) 149 self._page_sets = self._ParsePageSets(parse_options.page_sets)
146 150
147 self._record = parse_options.record 151 self._record = parse_options.record
148 self._skia_tools = parse_options.skia_tools 152 self._skia_tools = parse_options.skia_tools
149 self._non_interactive = parse_options.non_interactive 153 self._non_interactive = parse_options.non_interactive
150 self._upload = parse_options.upload 154 self._upload = parse_options.upload
155 self._skp_prefix = parse_options.skp_prefix
151 data_store_location = parse_options.data_store 156 data_store_location = parse_options.data_store
152 if data_store_location.startswith(gs_utils.GS_PREFIX): 157 if data_store_location.startswith(gs_utils.GS_PREFIX):
153 self.gs = GoogleStorageDataStore(data_store_location) 158 self.gs = GoogleStorageDataStore(data_store_location)
154 else: 159 else:
155 self.gs = LocalFileSystemDataStore(data_store_location) 160 self.gs = LocalFileSystemDataStore(data_store_location)
156 self._alternate_upload_dir = parse_options.alternate_upload_dir 161 self._alternate_upload_dir = parse_options.alternate_upload_dir
157 self._telemetry_binaries_dir = os.path.join(parse_options.chrome_src_path, 162 self._telemetry_binaries_dir = os.path.join(parse_options.chrome_src_path,
158 'tools', 'perf') 163 'tools', 'perf')
159 164
160 self._local_skp_dir = os.path.join( 165 self._local_skp_dir = os.path.join(
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 245
241 if self._IsChromiumPageSet(page_set): 246 if self._IsChromiumPageSet(page_set):
242 print 'Using Chromium\'s captured archives for Chromium\'s page sets.' 247 print 'Using Chromium\'s captured archives for Chromium\'s page sets.'
243 elif self._record: 248 elif self._record:
244 # Create an archive of the specified webpages if '--record=True' is 249 # Create an archive of the specified webpages if '--record=True' is
245 # specified. 250 # specified.
246 record_wpr_cmd = ( 251 record_wpr_cmd = (
247 'PYTHONPATH=%s:$PYTHONPATH' % page_set_dir, 252 'PYTHONPATH=%s:$PYTHONPATH' % page_set_dir,
248 'DISPLAY=%s' % X11_DISPLAY, 253 'DISPLAY=%s' % X11_DISPLAY,
249 os.path.join(self._telemetry_binaries_dir, 'record_wpr'), 254 os.path.join(self._telemetry_binaries_dir, 'record_wpr'),
250 '--extra-browser-args=--disable-setuid-sandbox', 255 '--extra-browser-args="%s"' % self._browser_args,
251 '--browser=exact', 256 '--browser=exact',
252 '--browser-executable=%s' % self._browser_executable, 257 '--browser-executable=%s' % self._browser_executable,
253 '%s_page_set' % page_set_basename, 258 '%s_page_set' % page_set_basename,
254 '--page-set-base-dir=%s' % page_set_dir 259 '--page-set-base-dir=%s' % page_set_dir
255 ) 260 )
256 for _ in range(RETRY_RECORD_WPR_COUNT): 261 for _ in range(RETRY_RECORD_WPR_COUNT):
257 try: 262 try:
258 shell_utils.run(' '.join(record_wpr_cmd), shell=True) 263 shell_utils.run(' '.join(record_wpr_cmd), shell=True)
259 264
260 # Move over the created archive into the local webpages archive 265 # Move over the created archive into the local webpages archive
(...skipping 18 matching lines...) Expand all
279 284
280 else: 285 else:
281 # Get the webpages archive so that it can be replayed. 286 # Get the webpages archive so that it can be replayed.
282 self._DownloadWebpagesArchive(wpr_data_file, page_set_json_name) 287 self._DownloadWebpagesArchive(wpr_data_file, page_set_json_name)
283 288
284 run_benchmark_cmd = ( 289 run_benchmark_cmd = (
285 'PYTHONPATH=%s:$PYTHONPATH' % page_set_dir, 290 'PYTHONPATH=%s:$PYTHONPATH' % page_set_dir,
286 'DISPLAY=%s' % X11_DISPLAY, 291 'DISPLAY=%s' % X11_DISPLAY,
287 'timeout', '300', 292 'timeout', '300',
288 os.path.join(self._telemetry_binaries_dir, 'run_benchmark'), 293 os.path.join(self._telemetry_binaries_dir, 'run_benchmark'),
289 '--extra-browser-args=--disable-setuid-sandbox', 294 '--extra-browser-args="%s"' % self._browser_args,
290 '--browser=exact', 295 '--browser=exact',
291 '--browser-executable=%s' % self._browser_executable, 296 '--browser-executable=%s' % self._browser_executable,
292 SKP_BENCHMARK, 297 SKP_BENCHMARK,
293 '--page-set-name=%s' % page_set_basename, 298 '--page-set-name=%s' % page_set_basename,
294 '--page-set-base-dir=%s' % page_set_dir, 299 '--page-set-base-dir=%s' % page_set_dir,
295 '--skp-outdir=%s' % TMP_SKP_DIR, 300 '--skp-outdir=%s' % TMP_SKP_DIR,
296 '--also-run-disabled-tests' 301 '--also-run-disabled-tests'
297 ) 302 )
298 303
299 for _ in range(RETRY_RUN_MEASUREMENT_COUNT): 304 for _ in range(RETRY_RUN_MEASUREMENT_COUNT):
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 .skp in there to be this page_set's representative .skp. 407 .skp in there to be this page_set's representative .skp.
403 """ 408 """
404 subdirs = glob.glob(os.path.join(TMP_SKP_DIR, '*')) 409 subdirs = glob.glob(os.path.join(TMP_SKP_DIR, '*'))
405 for site in subdirs: 410 for site in subdirs:
406 if self._IsChromiumPageSet(page_set): 411 if self._IsChromiumPageSet(page_set):
407 filename = self._GetChromiumSkpFileName(page_set, site) 412 filename = self._GetChromiumSkpFileName(page_set, site)
408 else: 413 else:
409 filename = self._GetSkiaSkpFileName(page_set) 414 filename = self._GetSkiaSkpFileName(page_set)
410 filename = filename.lower() 415 filename = filename.lower()
411 416
417 if self._skp_prefix:
418 filename = '%s%s' % (self._skp_prefix, filename)
419
412 # We choose the largest .skp as the most likely to be interesting. 420 # We choose the largest .skp as the most likely to be interesting.
413 largest_skp = max(glob.glob(os.path.join(site, '*.skp')), 421 largest_skp = max(glob.glob(os.path.join(site, '*.skp')),
414 key=lambda path: os.stat(path).st_size) 422 key=lambda path: os.stat(path).st_size)
415 dest = os.path.join(self._local_skp_dir, filename) 423 dest = os.path.join(self._local_skp_dir, filename)
416 print 'Moving', largest_skp, 'to', dest 424 print 'Moving', largest_skp, 'to', dest
417 shutil.move(largest_skp, dest) 425 shutil.move(largest_skp, dest)
418 self._skp_files.append(filename) 426 self._skp_files.append(filename)
419 shutil.rmtree(site) 427 shutil.rmtree(site)
420 428
421 def _CreateLocalStorageDirs(self): 429 def _CreateLocalStorageDirs(self):
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 option_parser.add_option( 547 option_parser.add_option(
540 '', '--output_dir', 548 '', '--output_dir',
541 help=('Temporary directory where SKPs and webpage archives will be ' 549 help=('Temporary directory where SKPs and webpage archives will be '
542 'outputted to.'), 550 'outputted to.'),
543 default=tempfile.gettempdir()) 551 default=tempfile.gettempdir())
544 option_parser.add_option( 552 option_parser.add_option(
545 '', '--browser_executable', 553 '', '--browser_executable',
546 help='The exact browser executable to run.', 554 help='The exact browser executable to run.',
547 default=None) 555 default=None)
548 option_parser.add_option( 556 option_parser.add_option(
557 '', '--browser_extra_args',
558 help='Additional arguments to pass to the browser.',
559 default=None)
560 option_parser.add_option(
549 '', '--chrome_src_path', 561 '', '--chrome_src_path',
550 help='Path to the chromium src directory.', 562 help='Path to the chromium src directory.',
551 default=None) 563 default=None)
552 option_parser.add_option( 564 option_parser.add_option(
553 '', '--non-interactive', action='store_true', 565 '', '--non-interactive', action='store_true',
554 help='Runs the script without any prompts. If this flag is specified and ' 566 help='Runs the script without any prompts. If this flag is specified and '
555 '--skia_tools is specified then the debugger is not run.', 567 '--skia_tools is specified then the debugger is not run.',
556 default=False) 568 default=False)
569 option_parser.add_option(
570 '', '--skp_prefix',
571 help='Prefix to add to the names of generated SKPs.',
572 default=None)
557 options, unused_args = option_parser.parse_args() 573 options, unused_args = option_parser.parse_args()
558 574
559 playback = SkPicturePlayback(options) 575 playback = SkPicturePlayback(options)
560 sys.exit(playback.Run()) 576 sys.exit(playback.Run())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698