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

Side by Side Diff: tools/android/loading/sandwich_task_builder.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 | « tools/android/loading/sandwich_runner.py ('k') | 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 # Copyright 2016 The Chromium Authors. All rights reserved. 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 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import csv 5 import csv
6 import json 6 import json
7 import os 7 import os
8 import shutil 8 import shutil
9 9
10 import chrome_cache 10 import chrome_cache
(...skipping 19 matching lines...) Expand all
30 def Transformer(runner): 30 def Transformer(runner):
31 assert isinstance(runner, sandwich_runner.SandwichRunner) 31 assert isinstance(runner, sandwich_runner.SandwichRunner)
32 runner.network_condition = network_condition 32 runner.network_condition = network_condition
33 return Transformer 33 return Transformer
34 34
35 35
36 class SandwichTaskBuilder(task_manager.Builder): 36 class SandwichTaskBuilder(task_manager.Builder):
37 """A builder for a graph of tasks, each prepares or invokes a SandwichRunner. 37 """A builder for a graph of tasks, each prepares or invokes a SandwichRunner.
38 """ 38 """
39 39
40 def __init__(self, output_directory, android_device, job_path, url_repeat): 40 def __init__(self, output_directory, android_device, job_path):
41 """Constructor. 41 """Constructor.
42 42
43 Args: 43 Args:
44 output_directory: As in task_manager.Builder.__init__ 44 output_directory: As in task_manager.Builder.__init__
45 android_device: The android DeviceUtils to run sandwich on or None to run 45 android_device: The android DeviceUtils to run sandwich on or None to run
46 it locally. 46 it locally.
47 job_path: Path of the sandwich's job. 47 job_path: Path of the sandwich's job.
48 url_repeat: Non null integer controlling how many times the URLs should be
49 repeated in the benchmarks.
50 """ 48 """
51 task_manager.Builder.__init__(self, output_directory) 49 task_manager.Builder.__init__(self, output_directory)
52 self._android_device = android_device 50 self._android_device = android_device
53 self._job_path = job_path 51 self._job_path = job_path
54 self._url_repeat = url_repeat
55 self._default_final_tasks = [] 52 self._default_final_tasks = []
56 53
57 self._original_wpr_task = None 54 self._original_wpr_task = None
58 self._patched_wpr_task = None 55 self._patched_wpr_task = None
59 self._reference_cache_task = None 56 self._reference_cache_task = None
60 self._subresources_for_urls_run_task = None 57 self._subresources_for_urls_run_task = None
61 self._subresources_for_urls_task = None 58 self._subresources_for_urls_task = None
62 59
63 @property 60 @property
64 def default_final_tasks(self): 61 def default_final_tasks(self):
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 149
153 self._patched_wpr_task = BuildPatchedWpr 150 self._patched_wpr_task = BuildPatchedWpr
154 self._reference_cache_task = BuildReferenceCache 151 self._reference_cache_task = BuildReferenceCache
155 self._subresources_for_urls_run_task = UrlsResourcesRun 152 self._subresources_for_urls_run_task = UrlsResourcesRun
156 self._subresources_for_urls_task = ListUrlsResources 153 self._subresources_for_urls_task = ListUrlsResources
157 154
158 self._default_final_tasks.append(ValidateReferenceCache) 155 self._default_final_tasks.append(ValidateReferenceCache)
159 return ValidateReferenceCache 156 return ValidateReferenceCache
160 157
161 def PopulateLoadBenchmark(self, subresource_discoverer, 158 def PopulateLoadBenchmark(self, subresource_discoverer,
162 runner_transformer_name, runner_transformer): 159 transformer_list_name, transformer_list):
163 """Populate benchmarking tasks from its setup tasks. 160 """Populate benchmarking tasks from its setup tasks.
164 161
165 Args: 162 Args:
166 subresource_discoverer: Name of a subresources discoverer. 163 subresource_discoverer: Name of a subresources discoverer.
167 runner_transformer: A function that takes an instance of SandwichRunner as 164 transformer_list_name: A string describing the transformers, will be used
168 parameter, would be applied immediately before SandwichRunner.Run(). 165 in Task names (prefer names without spaces and special characters).
169 runner_transformer_name: Name of the runner transformer used to generate 166 transformer_list: An ordered list of function that takes an instance of
170 task names. 167 SandwichRunner as parameter, would be applied immediately before
171 benchmark_name: The benchmark's name for that runner modifier. 168 SandwichRunner.Run() in the given order.
172 169
173 Here is the full dependency of the added tree for the returned task: 170 Here is the full dependency of the added tree for the returned task:
174 <runner_transformer_name>/<subresource_discoverer>-metrics.csv 171 <transformer_list_name>/<subresource_discoverer>-metrics.csv
175 depends on: <runner_transformer_name>/<subresource_discoverer>-run/ 172 depends on: <transformer_list_name>/<subresource_discoverer>-run/
176 depends on: common/<subresource_discoverer>-cache.zip 173 depends on: common/<subresource_discoverer>-cache.zip
177 depends on: some tasks saved by PopulateCommonPipelines() 174 depends on: some tasks saved by PopulateCommonPipelines()
178 depends on: common/<subresource_discoverer>-setup.json 175 depends on: common/<subresource_discoverer>-setup.json
179 depends on: some tasks saved by PopulateCommonPipelines() 176 depends on: some tasks saved by PopulateCommonPipelines()
180 177
181 Returns: 178 Returns:
182 task_manager.Task for 179 task_manager.Task for
183 <runner_transformer_name>/<subresource_discoverer>-metrics.csv 180 <transformer_list_name>/<subresource_discoverer>-metrics.csv
184 """ 181 """
185 assert subresource_discoverer in sandwich_misc.SUBRESOURCE_DISCOVERERS 182 assert subresource_discoverer in sandwich_misc.SUBRESOURCE_DISCOVERERS
186 assert 'common' not in sandwich_misc.SUBRESOURCE_DISCOVERERS 183 assert 'common' not in sandwich_misc.SUBRESOURCE_DISCOVERERS
187 shared_task_prefix = os.path.join('common', subresource_discoverer) 184 shared_task_prefix = os.path.join('common', subresource_discoverer)
188 task_prefix = os.path.join(runner_transformer_name, subresource_discoverer) 185 task_prefix = os.path.join(transformer_list_name, subresource_discoverer)
189 186
190 @self.RegisterTask(shared_task_prefix + '-setup.json', merge=True, 187 @self.RegisterTask(shared_task_prefix + '-setup.json', merge=True,
191 dependencies=[self._subresources_for_urls_task]) 188 dependencies=[self._subresources_for_urls_task])
192 def SetupBenchmark(): 189 def SetupBenchmark():
193 trace_path = os.path.join(self._subresources_for_urls_run_task.path, '0', 190 trace_path = os.path.join(self._subresources_for_urls_run_task.path, '0',
194 sandwich_runner.TRACE_FILENAME) 191 sandwich_runner.TRACE_FILENAME)
195 whitelisted_urls = sandwich_misc.ExtractDiscoverableUrls( 192 whitelisted_urls = sandwich_misc.ExtractDiscoverableUrls(
196 trace_path, subresource_discoverer) 193 trace_path, subresource_discoverer)
197 194
198 urls_resources = json.load(open(self._subresources_for_urls_task.path)) 195 urls_resources = json.load(open(self._subresources_for_urls_task.path))
(...skipping 15 matching lines...) Expand all
214 setup = json.load(open(SetupBenchmark.path)) 211 setup = json.load(open(SetupBenchmark.path))
215 chrome_cache.ApplyUrlWhitelistToCacheArchive( 212 chrome_cache.ApplyUrlWhitelistToCacheArchive(
216 cache_archive_path=self._reference_cache_task.path, 213 cache_archive_path=self._reference_cache_task.path,
217 whitelisted_urls=setup['cache_whitelist'], 214 whitelisted_urls=setup['cache_whitelist'],
218 output_cache_archive_path=BuildBenchmarkCacheArchive.path) 215 output_cache_archive_path=BuildBenchmarkCacheArchive.path)
219 216
220 @self.RegisterTask(task_prefix + '-run/', 217 @self.RegisterTask(task_prefix + '-run/',
221 dependencies=[BuildBenchmarkCacheArchive]) 218 dependencies=[BuildBenchmarkCacheArchive])
222 def RunBenchmark(): 219 def RunBenchmark():
223 runner = self._CreateSandwichRunner() 220 runner = self._CreateSandwichRunner()
224 # runner.record_video = True 221 for transformer in transformer_list:
225 runner.job_repeat = self._url_repeat 222 transformer(runner)
226 runner_transformer(runner)
227 runner.wpr_archive_path = self._patched_wpr_task.path 223 runner.wpr_archive_path = self._patched_wpr_task.path
228 runner.wpr_out_log_path = os.path.join(RunBenchmark.path, 'wpr.log') 224 runner.wpr_out_log_path = os.path.join(RunBenchmark.path, 'wpr.log')
229 runner.cache_archive_path = BuildBenchmarkCacheArchive.path 225 runner.cache_archive_path = BuildBenchmarkCacheArchive.path
230 runner.cache_operation = 'push' 226 runner.cache_operation = 'push'
231 runner.trace_output_directory = RunBenchmark.path 227 runner.trace_output_directory = RunBenchmark.path
232 runner.Run() 228 runner.Run()
233 229
234 @self.RegisterTask(task_prefix + '-metrics.csv', 230 @self.RegisterTask(task_prefix + '-metrics.csv',
235 dependencies=[RunBenchmark]) 231 dependencies=[RunBenchmark])
236 def ExtractMetrics(): 232 def ExtractMetrics():
237 sandwich_misc.VerifyBenchmarkOutputDirectory( 233 sandwich_misc.VerifyBenchmarkOutputDirectory(
238 SetupBenchmark.path, RunBenchmark.path) 234 SetupBenchmark.path, RunBenchmark.path)
239 trace_metrics_list = \ 235 trace_metrics_list = \
240 sandwich_metrics.ExtractMetricsFromRunnerOutputDirectory( 236 sandwich_metrics.ExtractMetricsFromRunnerOutputDirectory(
241 RunBenchmark.path) 237 RunBenchmark.path)
242 trace_metrics_list.sort(key=lambda e: e['repeat_id']) 238 trace_metrics_list.sort(key=lambda e: e['repeat_id'])
243 with open(ExtractMetrics.path, 'w') as csv_file: 239 with open(ExtractMetrics.path, 'w') as csv_file:
244 writer = csv.DictWriter(csv_file, 240 writer = csv.DictWriter(csv_file,
245 fieldnames=sandwich_metrics.CSV_FIELD_NAMES) 241 fieldnames=sandwich_metrics.CSV_FIELD_NAMES)
246 writer.writeheader() 242 writer.writeheader()
247 for trace_metrics in trace_metrics_list: 243 for trace_metrics in trace_metrics_list:
248 writer.writerow(trace_metrics) 244 writer.writerow(trace_metrics)
249 245
250 self._default_final_tasks.append(ExtractMetrics) 246 self._default_final_tasks.append(ExtractMetrics)
251 return ExtractMetrics 247 return ExtractMetrics
OLDNEW
« no previous file with comments | « tools/android/loading/sandwich_runner.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698