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

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/tool/commands/optimize_baselines.py

Issue 2128233003: Split out optimize-baselines command from rebaseline.py. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 | third_party/WebKit/Tools/Scripts/webkitpy/tool/commands/optimize_baselines_unittest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import logging
6 import optparse
7
8 from webkitpy.common.checkout.baselineoptimizer import BaselineOptimizer
9 from webkitpy.layout_tests.controllers.test_result_writer import baseline_name
10 from webkitpy.tool.commands.rebaseline import AbstractRebaseliningCommand
11
12
13 _log = logging.getLogger(__name__)
14
15
16 class OptimizeBaselines(AbstractRebaseliningCommand):
17 name = "optimize-baselines"
18 help_text = "Reshuffles the baselines for the given tests to use as litte sp ace on disk as possible."
19 show_in_main_help = True
20 argument_names = "TEST_NAMES"
21
22 def __init__(self):
23 super(OptimizeBaselines, self).__init__(options=[
24 self.suffixes_option,
25 optparse.make_option('--no-modify-scm', action='store_true', default =False,
26 help='Dump SCM commands as JSON instead of actu ally committing changes.'),
27 ] + self.platform_options)
28
29 def _optimize_baseline(self, optimizer, test_name):
30 files_to_delete = []
31 files_to_add = []
32 for suffix in self._baseline_suffix_list:
33 name = baseline_name(self._tool.filesystem, test_name, suffix)
34 succeeded, more_files_to_delete, more_files_to_add = optimizer.optim ize(name)
35 if not succeeded:
36 _log.error("Heuristics failed to optimize %s", name)
37 files_to_delete.extend(more_files_to_delete)
38 files_to_add.extend(more_files_to_add)
39 return files_to_delete, files_to_add
40
41 def execute(self, options, args, tool):
42 self._baseline_suffix_list = options.suffixes.split(',')
43 port_names = tool.port_factory.all_port_names(options.platform)
44 if not port_names:
45 _log.error("No port names match '%s'", options.platform)
46 return
47 port = tool.port_factory.get(port_names[0])
48 optimizer = BaselineOptimizer(tool, port, port_names, skip_scm_commands= options.no_modify_scm)
49 tests = port.tests(args)
50 for test_name in tests:
51 files_to_delete, files_to_add = self._optimize_baseline(optimizer, t est_name)
52 for path in files_to_delete:
53 self._delete_from_scm_later(path)
54 for path in files_to_add:
55 self._add_to_scm_later(path)
56 self._print_scm_changes()
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Tools/Scripts/webkitpy/tool/commands/optimize_baselines_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698