| Index: tools/perf/measurements/smoothness.py
|
| diff --git a/tools/perf/measurements/smoothness.py b/tools/perf/measurements/smoothness.py
|
| index a84a4acb29204c70fc9cc0627727bbbbafb73f5d..11628ccdcbc1907514d4f23d1e4f9224ac8c4282 100644
|
| --- a/tools/perf/measurements/smoothness.py
|
| +++ b/tools/perf/measurements/smoothness.py
|
| @@ -4,14 +4,26 @@
|
|
|
| from metrics import power
|
| from metrics import smoothness
|
| +from metrics import timeline_interaction_record as tir_module
|
| +from telemetry.core.timeline.model import TimelineModel
|
| from telemetry.page import page_measurement
|
|
|
| +import telemetry.core.timeline.bounds as timeline_bounds
|
| +
|
| +
|
| +class MissingDisplayFrameRateError(page_measurement.MeasurementFailure):
|
| + def __init__(self, name):
|
| + super(MissingDisplayFrameRateError, self).__init__(
|
| + 'Missing display frame rate metrics: ' + name)
|
| +
|
|
|
| class Smoothness(page_measurement.PageMeasurement):
|
| def __init__(self):
|
| super(Smoothness, self).__init__('smoothness')
|
| self._smoothness_metric = None
|
| self._power_metric = None
|
| + self._timeline_model = None
|
| + self._actions = []
|
|
|
| def CustomizeBrowserOptions(self, options):
|
| options.AppendExtraBrowserArgs('--enable-gpu-benchmarking')
|
| @@ -24,15 +36,46 @@ class Smoothness(page_measurement.PageMeasurement):
|
| self._power_metric = power.PowerMetric()
|
| self._power_metric.Start(page, tab)
|
| self._smoothness_metric = smoothness.SmoothnessMetric()
|
| - self._smoothness_metric.Start(page, tab)
|
| + # Start tracing for smoothness metric.
|
| + custom_categories = ['webkit.console', 'benchmark']
|
| + custom_categories += page.GetSyntheticDelayCategories()
|
| + tab.browser.StartTracing(','.join(custom_categories), 60)
|
| + if tab.browser.platform.IsRawDisplayFrameRateSupported():
|
| + tab.browser.platform.StartRawDisplayFrameRateMeasurement()
|
|
|
| def DidRunAction(self, page, tab, action):
|
| - self._smoothness_metric.AddActionToIncludeInMetric(action)
|
| + self._actions.append(action)
|
|
|
| def DidRunActions(self, page, tab):
|
| self._power_metric.Stop(page, tab)
|
| - self._smoothness_metric.Stop(page, tab)
|
| + # Stop tracing for smoothness metric.
|
| + if tab.browser.platform.IsRawDisplayFrameRateSupported():
|
| + tab.browser.platform.StopRawDisplayFrameRateMeasurement()
|
| + tracing_timeline_data = tab.browser.StopTracing()
|
| + self._timeline_model = TimelineModel(timeline_data=tracing_timeline_data)
|
|
|
| def MeasurePage(self, page, tab, results):
|
| self._power_metric.AddResults(tab, results)
|
| - self._smoothness_metric.AddResults(tab, results)
|
| + # Add results of smoothness metric. This computes the smoothness metric for
|
| + # the time range between the first action starts and the last action ends.
|
| + # To get the measurement for each action, use
|
| + # measurement.TimelineBasedMeasurement.
|
| + time_bounds = timeline_bounds.Bounds()
|
| + for action in self._actions:
|
| + time_bounds.AddBounds(
|
| + action.GetActiveRangeOnTimeline(self._timeline_model))
|
| + # Create an interaction_record for this legacy measurement. Since we don't
|
| + # wrap the results that is sent to smoothnes metric, the logical_name will
|
| + # not be used.
|
| + interaction_record = tir_module.TimelineInteractionRecord(
|
| + 'smoothness_interaction', time_bounds.min, time_bounds.max)
|
| + renderer_thread = self._timeline_model.GetRendererThreadFromTab(tab)
|
| + self._smoothness_metric.AddResults(self._timeline_model,
|
| + renderer_thread,
|
| + interaction_record,
|
| + results)
|
| + if tab.browser.platform.IsRawDisplayFrameRateSupported():
|
| + for r in tab.browser.platform.GetRawDisplayFrameRateMeasurements():
|
| + if r.value is None:
|
| + raise MissingDisplayFrameRateError(r.name)
|
| + results.Add(r.name, r.unit, r.value)
|
|
|