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

Unified Diff: telemetry/telemetry/web_perf/timeline_based_measurement.py

Issue 2162963002: [polymer] Merge of master into polymer10-migration (Closed) Base URL: git@github.com:catapult-project/catapult.git@polymer10-migration
Patch Set: Merge polymer10-migration int polymer10-merge 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 side-by-side diff with in-line comments
Download patch
Index: telemetry/telemetry/web_perf/timeline_based_measurement.py
diff --git a/telemetry/telemetry/web_perf/timeline_based_measurement.py b/telemetry/telemetry/web_perf/timeline_based_measurement.py
index 1482656d29d74cbf280b9cc3fb67ee6442c0e8dc..0334438bc34eb120e318bedfc32f3f137f83cb56 100644
--- a/telemetry/telemetry/web_perf/timeline_based_measurement.py
+++ b/telemetry/telemetry/web_perf/timeline_based_measurement.py
@@ -7,8 +7,8 @@ from collections import defaultdict
from tracing.metrics import metric_runner
+from telemetry.timeline import chrome_trace_category_filter
from telemetry.timeline import model as model_module
-from telemetry.timeline import tracing_category_filter
from telemetry.timeline import tracing_config
from telemetry.value import trace
from telemetry.value import common_value_helpers
@@ -30,14 +30,14 @@ from telemetry.web_perf import timeline_interaction_record as tir_module
# timeline. But, depending on the amount of instrumentation that is enabled,
# overhead increases. The user of the measurement must therefore chose between
# a few levels of instrumentation.
-NO_OVERHEAD_LEVEL = 'no-overhead'
-MINIMAL_OVERHEAD_LEVEL = 'minimal-overhead'
+LOW_OVERHEAD_LEVEL = 'low-overhead'
+DEFAULT_OVERHEAD_LEVEL = 'default-overhead'
DEBUG_OVERHEAD_LEVEL = 'debug-overhead'
ALL_OVERHEAD_LEVELS = [
- NO_OVERHEAD_LEVEL,
- MINIMAL_OVERHEAD_LEVEL,
- DEBUG_OVERHEAD_LEVEL
+ LOW_OVERHEAD_LEVEL,
+ DEFAULT_OVERHEAD_LEVEL,
+ DEBUG_OVERHEAD_LEVEL,
]
@@ -159,16 +159,16 @@ class Options(object):
By default, all the timeline based metrics in telemetry/web_perf/metrics are
used (see _GetAllLegacyTimelineBasedMetrics above).
- To customize your metric needs, use SetTimelineBasedMetric().
+ To customize your metric needs, use SetTimelineBasedMetrics().
"""
- def __init__(self, overhead_level=NO_OVERHEAD_LEVEL):
+ def __init__(self, overhead_level=LOW_OVERHEAD_LEVEL):
"""As the amount of instrumentation increases, so does the overhead.
The user of the measurement chooses the overhead level that is appropriate,
and the tracing is filtered accordingly.
- overhead_level: Can either be a custom TracingCategoryFilter object or
- one of NO_OVERHEAD_LEVEL, MINIMAL_OVERHEAD_LEVEL or
+ overhead_level: Can either be a custom ChromeTraceCategoryFilter object or
+ one of LOW_OVERHEAD_LEVEL, DEFAULT_OVERHEAD_LEVEL or
DEBUG_OVERHEAD_LEVEL.
"""
self._config = tracing_config.TracingConfig()
@@ -176,52 +176,55 @@ class Options(object):
self._config.enable_platform_display_trace = False
if isinstance(overhead_level,
- tracing_category_filter.TracingCategoryFilter):
- self._config.chrome_trace_config.SetTracingCategoryFilter(overhead_level)
+ chrome_trace_category_filter.ChromeTraceCategoryFilter):
+ self._config.chrome_trace_config.SetCategoryFilter(overhead_level)
elif overhead_level in ALL_OVERHEAD_LEVELS:
- if overhead_level == NO_OVERHEAD_LEVEL:
- self._config.chrome_trace_config.SetNoOverheadFilter()
- elif overhead_level == MINIMAL_OVERHEAD_LEVEL:
- self._config.chrome_trace_config.SetMinimalOverheadFilter()
+ if overhead_level == LOW_OVERHEAD_LEVEL:
+ self._config.chrome_trace_config.SetLowOverheadFilter()
+ elif overhead_level == DEFAULT_OVERHEAD_LEVEL:
+ self._config.chrome_trace_config.SetDefaultOverheadFilter()
else:
self._config.chrome_trace_config.SetDebugOverheadFilter()
else:
- raise Exception("Overhead level must be a TracingCategoryFilter object"
- " or valid overhead level string."
- " Given overhead level: %s" % overhead_level)
+ raise Exception("Overhead level must be a ChromeTraceCategoryFilter "
+ "object or valid overhead level string. Given overhead "
+ "level: %s" % overhead_level)
- self._timeline_based_metric = None
+ self._timeline_based_metrics = None
self._legacy_timeline_based_metrics = []
def ExtendTraceCategoryFilter(self, filters):
- category_filter = self._config.chrome_trace_config.tracing_category_filter
+ category_filter = self._config.chrome_trace_config.category_filter
for new_category_filter in filters:
category_filter.AddIncludedCategory(new_category_filter)
@property
def category_filter(self):
- return self._config.chrome_trace_config.tracing_category_filter
+ return self._config.chrome_trace_config.category_filter
@property
def config(self):
return self._config
- def SetTimelineBasedMetric(self, metric):
- """Sets the new-style (TBMv2) metric to run.
+ def SetTimelineBasedMetrics(self, metrics):
+ """Sets the new-style (TBMv2) metrics to run.
- Metrics are assumed to live in //tracing/tracing/metrics, so the path
- should be relative to that. For example, to specify sample_metric.html,
- you would pass 'sample_metric.html'.
+ Metrics are assumed to live in //tracing/tracing/metrics, so the path you
+ pass in should be relative to that. For example, to specify
+ sample_metric.html, you should pass in ['sample_metric.html'].
Args:
- metric: A string metric path under //tracing/tracing/metrics.
+ metrics: A list of strings giving metric paths under
+ //tracing/tracing/metrics.
"""
- assert isinstance(metric, basestring)
- self._timeline_based_metric = metric
+ assert isinstance(metrics, list)
+ for metric in metrics:
+ assert isinstance(metric, basestring)
+ self._timeline_based_metrics = metrics
- def GetTimelineBasedMetric(self):
- return self._timeline_based_metric
+ def GetTimelineBasedMetrics(self):
+ return self._timeline_based_metrics
def SetLegacyTimelineBasedMetrics(self, metrics):
assert isinstance(metrics, collections.Iterable)
@@ -279,8 +282,8 @@ class TimelineBasedMeasurement(story_test.StoryTest):
trace_value = trace.TraceValue(results.current_page, trace_result)
results.AddValue(trace_value)
- if self._tbm_options.GetTimelineBasedMetric():
- self._ComputeTimelineBasedMetric(results, trace_value)
+ if self._tbm_options.GetTimelineBasedMetrics():
+ self._ComputeTimelineBasedMetrics(results, trace_value)
# Legacy metrics can be computed, but only if explicitly specified.
if self._tbm_options.GetLegacyTimelineBasedMetrics():
self._ComputeLegacyTimelineBasedMetrics(results, trace_result)
@@ -299,14 +302,14 @@ class TimelineBasedMeasurement(story_test.StoryTest):
if platform.tracing_controller.is_tracing_running:
platform.tracing_controller.StopTracing()
- def _ComputeTimelineBasedMetric(self, results, trace_value):
- metric = self._tbm_options.GetTimelineBasedMetric()
+ def _ComputeTimelineBasedMetrics(self, results, trace_value):
+ metrics = self._tbm_options.GetTimelineBasedMetrics()
extra_import_options = {
'trackDetailedModelStats': True
}
mre_result = metric_runner.RunMetric(
- trace_value.filename, metric, extra_import_options)
+ trace_value.filename, metrics, extra_import_options)
page = results.current_page
failure_dicts = mre_result.failures

Powered by Google App Engine
This is Rietveld 408576698