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

Unified Diff: tools/perf/measurements/timeline_based_measurement.py

Issue 200843002: Convert smoothness to the new timeline based metric API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 9 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: tools/perf/measurements/timeline_based_measurement.py
diff --git a/tools/perf/measurements/timeline_based_measurement.py b/tools/perf/measurements/timeline_based_measurement.py
index 8568bb10ac6235dba804672cff50e3f1b944f1cb..b06fa85079f837ca5b16daa38c5127dd53b3c5f7 100644
--- a/tools/perf/measurements/timeline_based_measurement.py
+++ b/tools/perf/measurements/timeline_based_measurement.py
@@ -4,11 +4,11 @@
from metrics import timeline as timeline_module
from metrics import timeline_interaction_record as tir_module
+from metrics import smoothness
from telemetry.page import page_measurement
from telemetry.core.timeline import model as model_module
-
# TimelineBasedMeasurement considers all instrumentation as producing a single
# timeline. But, depending on the amount of instrumentation that is enabled,
# overhead increases. The user of the measurement must therefore chose between
@@ -24,6 +24,21 @@ ALL_OVERHEAD_LEVELS = [
]
+class _ResultsWrapper(object):
+ def __init__(self, results, interaction_record):
+ self._results = results
+ self._interaction_record = interaction_record
+
+ def Add(self, trace_name, units, value, chart_name=None, data_type='default'):
+ trace_name = self._interaction_record.GetResultNameFor(trace_name)
+ self._results.Add(trace_name, units, value, chart_name, data_type)
+
+ def AddSummary(self, trace_name, units, value, chart_name=None,
+ data_type='default'):
+ trace_name = self._interaction_record.GetResultNameFor(trace_name)
+ self._results.AddSummary(trace_name, units, value, chart_name, data_type)
+
+
class _TimelineBasedMetrics(object):
def __init__(self, model, renderer_thread):
self._model = model
@@ -31,14 +46,14 @@ class _TimelineBasedMetrics(object):
def FindTimelineInteractionRecords(self):
# TODO(nduca): Add support for page-load interaction record.
- return [tir_module.TimelineInteractionRecord(event) for
+ return [tir_module.TimelineInteractionRecord.FromEvent(event) for
event in self._renderer_thread.IterAllAsyncSlices()
if tir_module.IsTimelineInteractionRecord(event.name)]
def CreateMetricsForTimelineInteractionRecord(self, interaction):
res = []
if interaction.is_smooth:
- pass # TODO(nduca): res.append smoothness metric instance.
+ res.append(smoothness.SmoothnessMetric())
return res
def AddResults(self, results):
@@ -47,9 +62,10 @@ class _TimelineBasedMetrics(object):
raise Exception('Expected at least one Interaction on the page')
for interaction in interactions:
metrics = self.CreateMetricsForTimelineInteractionRecord(interaction)
+ wrapped_results = _ResultsWrapper(results, interaction)
for m in metrics:
m.AddResults(self._model, self._renderer_thread,
- interaction, results)
+ interaction, wrapped_results)
class TimelineBasedMeasurement(page_measurement.PageMeasurement):
@@ -97,6 +113,7 @@ class TimelineBasedMeasurement(page_measurement.PageMeasurement):
categories = ''
else:
categories = '*,disabled-by-default-cc.debug'
+ categories = ','.join([categories] + page.GetSyntheticDelayCategories())
tab.browser.StartTracing(categories)
def MeasurePage(self, page, tab, results):
« no previous file with comments | « tools/perf/measurements/smoothness_unittest.py ('k') | tools/perf/measurements/timeline_based_measurement_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698