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

Unified Diff: telemetry/telemetry/benchmark.py

Issue 2965383002: WIP: Add support for additional flag-specified tracing categories. (Closed)
Patch Set: Created 3 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 side-by-side diff with in-line comments
Download patch
Index: telemetry/telemetry/benchmark.py
diff --git a/telemetry/telemetry/benchmark.py b/telemetry/telemetry/benchmark.py
index a04d6b2f2cd14f3a2d20381772e19f6495f511f7..239c823ea1d584220e6f073dc9bb2ebca0e37840 100644
--- a/telemetry/telemetry/benchmark.py
+++ b/telemetry/telemetry/benchmark.py
@@ -72,12 +72,14 @@ class Benchmark(command_line.Command):
self._max_failures = max_failures
self._has_original_tbm_options = (
self.CreateTimelineBasedMeasurementOptions.__func__ ==
- Benchmark.CreateTimelineBasedMeasurementOptions.__func__)
+ Benchmark.CreateTimelineBasedMeasurementOptions.__func__ or
+ self.CreateBaseTimelineBasedMeasurementOptions.__func__ ==
+ Benchmark.CreateBaseTimelineBasedMeasurementOptions.__func__)
has_original_create_page_test = (
self.CreatePageTest.__func__ == Benchmark.CreatePageTest.__func__)
assert self._has_original_tbm_options or has_original_create_page_test, (
'Cannot override both CreatePageTest and '
- 'CreateTimelineBasedMeasurementOptions.')
+ 'CreateBaseTimelineBasedMeasurementOptions.')
# pylint: disable=unused-argument
@classmethod
@@ -228,20 +230,64 @@ class Benchmark(command_line.Command):
return histogram.Ownership(decorators.GetEmails(self),
decorators.GetComponent(self))
+ @decorators.Deprecated(
+ 2017, 9, 1, 'Use CreateBaseTimelineBasedMeasurementOptions instead.')
def CreateTimelineBasedMeasurementOptions(self):
- """Return the TimelineBasedMeasurementOptions for this Benchmark.
+ """See CreateBaseTimelineBasedMeasurementOptions."""
+ return self.CreateBaseTimelineBasedMeasurementOptions()
- Override this method to configure a TimelineBasedMeasurement benchmark.
- Otherwise, override CreatePageTest for PageTest tests. Do not override
- both methods.
+ def CreateBaseTimelineBasedMeasurementOptions(self):
charliea (OOO until 10-5) 2017/07/07 20:06:59 I think this could use clarification on what "base
+ """Return the base TimelineBasedMeasurementOptions for this Benchmark.
+
+ Additional chrome and atrace categories can be appended when running the
+ benchmark with the --extra-chrome-categories and --extra-atrace-categories
+ flags.
+
+ Override this method to configure a TimelineBasedMeasurement benchmark. If
+ this is not a TimelineBasedMeasurement benchmark, override CreatePageTest
+ for PageTest tests. Do not override both methods.
"""
return timeline_based_measurement.Options()
+ def _GetTimelineBasedMeasurementOptions(self, options):
+ """Return all timeline based measurements for the curren benchmark run.
+
+ This includes the benchmark-configured measurements in
+ CreateBaseTimelineBasedMeasurementOptions as well as the user-flag-
+ configured options from --extra-chrome-categories and
+ --extra-atrace-categories.
+ """
+ # TODO(sullivan): the benchmark options should all be configured in
+ # CreateBaseTimelineBasedMeasurementOptions. Remove references to
+ # CreateTimelineBasedMeasurementOptions when it is fully deprecated.
+ # In the short term, if the benchmark overrides
+ # CreateTimelineBasedMeasurementOptions use the overridden version,
+ # otherwise call CreateBaseTimelineBasedMeasurementOptions.
+ # https://github.com/catapult-project/catapult/issues/3450
+ tbm_options = None
+ if (self.CreateTimelineBasedMeasurementOptions.__func__ !=
+ Benchmark.CreateTimelineBasedMeasurementOptions.__func__):
+ tbm_options = self.CreateTimelineBasedMeasurementOptions()
+ else:
+ tbm_options = self.CreateBaseTimelineBasedMeasurementOptions()
+ if options.extra_chrome_categories:
+ assert tbm_options.enable_chrome_trace, (
+ '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
+ 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
+ options.extra_chrome_categories)
+ if options.extra_atrace_categories:
+ assert tbm_options.enable_atrace_trace, (
+ '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
+ tbm_options.atrace_config.categories.append(
+ options.extra_atrace_categories.split(','))
+ return tbm_options
+
+
def CreatePageTest(self, options): # pylint: disable=unused-argument
"""Return the PageTest for this Benchmark.
Override this method for PageTest tests.
- Override, override CreateTimelineBasedMeasurementOptions to configure
+ Override, CreateBaseTimelineBasedMeasurementOptions to configure
TimelineBasedMeasurement tests. Do not override both methods.
Args:
@@ -257,11 +303,11 @@ class Benchmark(command_line.Command):
self.test.__name__)
if is_page_test:
assert self._has_original_tbm_options, (
- 'Cannot override CreateTimelineBasedMeasurementOptions '
+ 'Cannot override CreateBaseTimelineBasedMeasurementOptions '
'with a PageTest.')
return self.test() # pylint: disable=no-value-for-parameter
- opts = self.CreateTimelineBasedMeasurementOptions()
+ opts = self._GetTimelineBasedMeasurementOptions(options)
self.SetupTraceRerunOptions(options, opts)
return timeline_based_measurement.TimelineBasedMeasurement(opts)

Powered by Google App Engine
This is Rietveld 408576698