OLD | NEW |
---|---|
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 optparse | 5 import optparse |
6 | 6 |
7 from telemetry import decorators | 7 from telemetry import decorators |
8 from telemetry.internal import story_runner | 8 from telemetry.internal import story_runner |
9 from telemetry.internal.util import command_line | 9 from telemetry.internal.util import command_line |
10 from telemetry.page import legacy_page_test | 10 from telemetry.page import legacy_page_test |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
65 """Creates a new Benchmark. | 65 """Creates a new Benchmark. |
66 | 66 |
67 Args: | 67 Args: |
68 max_failures: The number of story run's failures before bailing | 68 max_failures: The number of story run's failures before bailing |
69 from executing subsequent page runs. If None, we never bail. | 69 from executing subsequent page runs. If None, we never bail. |
70 """ | 70 """ |
71 self._expectations = None | 71 self._expectations = None |
72 self._max_failures = max_failures | 72 self._max_failures = max_failures |
73 self._has_original_tbm_options = ( | 73 self._has_original_tbm_options = ( |
74 self.CreateTimelineBasedMeasurementOptions.__func__ == | 74 self.CreateTimelineBasedMeasurementOptions.__func__ == |
75 Benchmark.CreateTimelineBasedMeasurementOptions.__func__) | 75 Benchmark.CreateTimelineBasedMeasurementOptions.__func__ or |
76 self.CreateBaseTimelineBasedMeasurementOptions.__func__ == | |
77 Benchmark.CreateBaseTimelineBasedMeasurementOptions.__func__) | |
76 has_original_create_page_test = ( | 78 has_original_create_page_test = ( |
77 self.CreatePageTest.__func__ == Benchmark.CreatePageTest.__func__) | 79 self.CreatePageTest.__func__ == Benchmark.CreatePageTest.__func__) |
78 assert self._has_original_tbm_options or has_original_create_page_test, ( | 80 assert self._has_original_tbm_options or has_original_create_page_test, ( |
79 'Cannot override both CreatePageTest and ' | 81 'Cannot override both CreatePageTest and ' |
80 'CreateTimelineBasedMeasurementOptions.') | 82 'CreateBaseTimelineBasedMeasurementOptions.') |
81 | 83 |
82 # pylint: disable=unused-argument | 84 # pylint: disable=unused-argument |
83 @classmethod | 85 @classmethod |
84 def ShouldDisable(cls, possible_browser): | 86 def ShouldDisable(cls, possible_browser): |
85 """Override this method to disable a benchmark under specific conditions. | 87 """Override this method to disable a benchmark under specific conditions. |
86 | 88 |
87 Supports logic too complex for simple Enabled and Disabled decorators. | 89 Supports logic too complex for simple Enabled and Disabled decorators. |
88 Decorators are still respected in cases where this function returns False. | 90 Decorators are still respected in cases where this function returns False. |
89 """ | 91 """ |
90 return False | 92 return False |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
221 | 223 |
222 def GetOwnership(self): | 224 def GetOwnership(self): |
223 """Returns an Ownership Diagnostic containing the benchmark's information. | 225 """Returns an Ownership Diagnostic containing the benchmark's information. |
224 | 226 |
225 Returns: | 227 Returns: |
226 Diagnostic with the benchmark's owners' e-mails and component name | 228 Diagnostic with the benchmark's owners' e-mails and component name |
227 """ | 229 """ |
228 return histogram.Ownership(decorators.GetEmails(self), | 230 return histogram.Ownership(decorators.GetEmails(self), |
229 decorators.GetComponent(self)) | 231 decorators.GetComponent(self)) |
230 | 232 |
233 @decorators.Deprecated( | |
234 2017, 9, 1, 'Use CreateBaseTimelineBasedMeasurementOptions instead.') | |
231 def CreateTimelineBasedMeasurementOptions(self): | 235 def CreateTimelineBasedMeasurementOptions(self): |
232 """Return the TimelineBasedMeasurementOptions for this Benchmark. | 236 """See CreateBaseTimelineBasedMeasurementOptions.""" |
237 return self.CreateBaseTimelineBasedMeasurementOptions() | |
233 | 238 |
234 Override this method to configure a TimelineBasedMeasurement benchmark. | 239 def CreateBaseTimelineBasedMeasurementOptions(self): |
charliea (OOO until 10-5)
2017/07/07 20:06:59
I think this could use clarification on what "base
| |
235 Otherwise, override CreatePageTest for PageTest tests. Do not override | 240 """Return the base TimelineBasedMeasurementOptions for this Benchmark. |
236 both methods. | 241 |
242 Additional chrome and atrace categories can be appended when running the | |
243 benchmark with the --extra-chrome-categories and --extra-atrace-categories | |
244 flags. | |
245 | |
246 Override this method to configure a TimelineBasedMeasurement benchmark. If | |
247 this is not a TimelineBasedMeasurement benchmark, override CreatePageTest | |
248 for PageTest tests. Do not override both methods. | |
237 """ | 249 """ |
238 return timeline_based_measurement.Options() | 250 return timeline_based_measurement.Options() |
239 | 251 |
252 def _GetTimelineBasedMeasurementOptions(self, options): | |
253 """Return all timeline based measurements for the curren benchmark run. | |
254 | |
255 This includes the benchmark-configured measurements in | |
256 CreateBaseTimelineBasedMeasurementOptions as well as the user-flag- | |
257 configured options from --extra-chrome-categories and | |
258 --extra-atrace-categories. | |
259 """ | |
260 # TODO(sullivan): the benchmark options should all be configured in | |
261 # CreateBaseTimelineBasedMeasurementOptions. Remove references to | |
262 # CreateTimelineBasedMeasurementOptions when it is fully deprecated. | |
263 # In the short term, if the benchmark overrides | |
264 # CreateTimelineBasedMeasurementOptions use the overridden version, | |
265 # otherwise call CreateBaseTimelineBasedMeasurementOptions. | |
266 # https://github.com/catapult-project/catapult/issues/3450 | |
267 tbm_options = None | |
268 if (self.CreateTimelineBasedMeasurementOptions.__func__ != | |
269 Benchmark.CreateTimelineBasedMeasurementOptions.__func__): | |
270 tbm_options = self.CreateTimelineBasedMeasurementOptions() | |
271 else: | |
272 tbm_options = self.CreateBaseTimelineBasedMeasurementOptions() | |
273 if options.extra_chrome_categories: | |
274 assert tbm_options.enable_chrome_trace, ( | |
275 'This benchmark does not support Chrome tracing.') | |
sullivan
2017/07/07 14:58:47
Copied this from the bug comment. Big question I h
charliea (OOO until 10-5)
2017/07/07 20:06:59
One thing that jumps out to me is that it's not cl
nednguyen
2017/07/07 20:07:50
I think most benchmark that support Chrome tracing
| |
276 tbm_options.chrome_trace_config.category_filter.AddFilterString( | |
sullivan
2017/07/07 14:58:47
Also copied this from the bug comment. Any reason
charliea (OOO until 10-5)
2017/07/07 20:06:59
My understanding was that the filter string was th
nednguyen
2017/07/07 20:07:50
To avoid explosion number of flags. I think the pe
| |
277 options.extra_chrome_categories) | |
278 if options.extra_atrace_categories: | |
279 assert tbm_options.enable_atrace_trace, ( | |
280 'This benchmark does not support atrace.') | |
sullivan
2017/07/07 14:58:47
Same question about enabling atrace.
nednguyen
2017/07/07 20:07:50
Same as above
| |
281 tbm_options.atrace_config.categories.append( | |
282 options.extra_atrace_categories.split(',')) | |
283 return tbm_options | |
284 | |
285 | |
240 def CreatePageTest(self, options): # pylint: disable=unused-argument | 286 def CreatePageTest(self, options): # pylint: disable=unused-argument |
241 """Return the PageTest for this Benchmark. | 287 """Return the PageTest for this Benchmark. |
242 | 288 |
243 Override this method for PageTest tests. | 289 Override this method for PageTest tests. |
244 Override, override CreateTimelineBasedMeasurementOptions to configure | 290 Override, CreateBaseTimelineBasedMeasurementOptions to configure |
245 TimelineBasedMeasurement tests. Do not override both methods. | 291 TimelineBasedMeasurement tests. Do not override both methods. |
246 | 292 |
247 Args: | 293 Args: |
248 options: a browser_options.BrowserFinderOptions instance | 294 options: a browser_options.BrowserFinderOptions instance |
249 Returns: | 295 Returns: |
250 |test()| if |test| is a PageTest class. | 296 |test()| if |test| is a PageTest class. |
251 Otherwise, a TimelineBasedMeasurement instance. | 297 Otherwise, a TimelineBasedMeasurement instance. |
252 """ | 298 """ |
253 is_page_test = issubclass(self.test, legacy_page_test.LegacyPageTest) | 299 is_page_test = issubclass(self.test, legacy_page_test.LegacyPageTest) |
254 is_tbm = self.test == timeline_based_measurement.TimelineBasedMeasurement | 300 is_tbm = self.test == timeline_based_measurement.TimelineBasedMeasurement |
255 if not is_page_test and not is_tbm: | 301 if not is_page_test and not is_tbm: |
256 raise TypeError('"%s" is not a PageTest or a TimelineBasedMeasurement.' % | 302 raise TypeError('"%s" is not a PageTest or a TimelineBasedMeasurement.' % |
257 self.test.__name__) | 303 self.test.__name__) |
258 if is_page_test: | 304 if is_page_test: |
259 assert self._has_original_tbm_options, ( | 305 assert self._has_original_tbm_options, ( |
260 'Cannot override CreateTimelineBasedMeasurementOptions ' | 306 'Cannot override CreateBaseTimelineBasedMeasurementOptions ' |
261 'with a PageTest.') | 307 'with a PageTest.') |
262 return self.test() # pylint: disable=no-value-for-parameter | 308 return self.test() # pylint: disable=no-value-for-parameter |
263 | 309 |
264 opts = self.CreateTimelineBasedMeasurementOptions() | 310 opts = self._GetTimelineBasedMeasurementOptions(options) |
265 self.SetupTraceRerunOptions(options, opts) | 311 self.SetupTraceRerunOptions(options, opts) |
266 return timeline_based_measurement.TimelineBasedMeasurement(opts) | 312 return timeline_based_measurement.TimelineBasedMeasurement(opts) |
267 | 313 |
268 def CreateStorySet(self, options): | 314 def CreateStorySet(self, options): |
269 """Creates the instance of StorySet used to run the benchmark. | 315 """Creates the instance of StorySet used to run the benchmark. |
270 | 316 |
271 Can be overridden by subclasses. | 317 Can be overridden by subclasses. |
272 """ | 318 """ |
273 del options # unused | 319 del options # unused |
274 # TODO(aiolos, nednguyen, eakufner): replace class attribute page_set with | 320 # TODO(aiolos, nednguyen, eakufner): replace class attribute page_set with |
(...skipping 29 matching lines...) Expand all Loading... | |
304 """ | 350 """ |
305 return expectations.StoryExpectations() | 351 return expectations.StoryExpectations() |
306 | 352 |
307 | 353 |
308 def AddCommandLineArgs(parser): | 354 def AddCommandLineArgs(parser): |
309 story_runner.AddCommandLineArgs(parser) | 355 story_runner.AddCommandLineArgs(parser) |
310 | 356 |
311 | 357 |
312 def ProcessCommandLineArgs(parser, args): | 358 def ProcessCommandLineArgs(parser, args): |
313 story_runner.ProcessCommandLineArgs(parser, args) | 359 story_runner.ProcessCommandLineArgs(parser, args) |
OLD | NEW |