diff options
Diffstat (limited to 'tools/perf/measurements/smoothness.py')
-rw-r--r-- | tools/perf/measurements/smoothness.py | 72 |
1 files changed, 28 insertions, 44 deletions
diff --git a/tools/perf/measurements/smoothness.py b/tools/perf/measurements/smoothness.py index 4fd0ad3..7d3e391 100644 --- a/tools/perf/measurements/smoothness.py +++ b/tools/perf/measurements/smoothness.py @@ -3,25 +3,27 @@ # found in the LICENSE file. from metrics import smoothness -from metrics.rendering_stats import RenderingStats +from metrics import rendering_stats from telemetry.page import page_test from telemetry.page import page_measurement +from telemetry.core.timeline.model import MarkerMismatchError -class DidNotScrollException(page_measurement.MeasurementFailure): +class NotEnoughFramesError(page_measurement.MeasurementFailure): def __init__(self): - super(DidNotScrollException, self).__init__('Page did not scroll') + super(NotEnoughFramesError, self).__init__( + 'Page output less than two frames') -class MissingDisplayFrameRate(page_measurement.MeasurementFailure): +class MissingDisplayFrameRateError(page_measurement.MeasurementFailure): def __init__(self, name): - super(MissingDisplayFrameRate, self).__init__( + super(MissingDisplayFrameRateError, self).__init__( 'Missing display frame rate metrics: ' + name) -class NoSupportedActionException(page_measurement.MeasurementFailure): +class NoSupportedActionError(page_measurement.MeasurementFailure): def __init__(self): - super(NoSupportedActionException, self).__init__( + super(NoSupportedActionError, self).__init__( 'None of the actions is supported by smoothness measurement') @@ -33,18 +35,17 @@ def GetTimelineMarkerLabelsFromAction(compound_action): if action.GetTimelineMarkerLabel(): timeline_marker_labels.append(action.GetTimelineMarkerLabel()) if not timeline_marker_labels: - raise NoSupportedActionException() + raise NoSupportedActionError() return timeline_marker_labels class Smoothness(page_measurement.PageMeasurement): def __init__(self): super(Smoothness, self).__init__('smoothness') - self._metrics = None self._trace_result = None def CustomizeBrowserOptions(self, options): - smoothness.SmoothnessMetrics.CustomizeBrowserOptions(options) + options.AppendExtraBrowserArgs('--enable-gpu-benchmarking') def CanRunForPage(self, page): return hasattr(page, 'smoothness') @@ -55,57 +56,40 @@ class Smoothness(page_measurement.PageMeasurement): tab.browser.StartTracing('webkit,webkit.console,benchmark', 60) if tab.browser.platform.IsRawDisplayFrameRateSupported(): tab.browser.platform.StartRawDisplayFrameRateMeasurement() - self._metrics = smoothness.SmoothnessMetrics(tab) - if action.CanBeBound(): - self._metrics.BindToAction(action) - else: - self._metrics.Start() - tab.ExecuteJavaScript( - 'console.time("' + smoothness.RENDER_PROCESS_MARKER + '")') + tab.ExecuteJavaScript( + 'console.time("' + rendering_stats.RENDER_PROCESS_MARKER + '")') def DidRunAction(self, page, tab, action): + tab.ExecuteJavaScript( + 'console.timeEnd("' + rendering_stats.RENDER_PROCESS_MARKER + '")') if tab.browser.platform.IsRawDisplayFrameRateSupported(): tab.browser.platform.StopRawDisplayFrameRateMeasurement() - if not action.CanBeBound(): - tab.ExecuteJavaScript( - 'console.timeEnd("' + smoothness.RENDER_PROCESS_MARKER + '")') - self._metrics.Stop() self._trace_result = tab.browser.StopTracing() def MeasurePage(self, page, tab, results): - rendering_stats_deltas = self._metrics.deltas - - # TODO(ernstm): remove numFramesSentToScreen when RenderingStats - # cleanup CL was picked up by the reference build. - if 'frameCount' in rendering_stats_deltas: - frame_count = rendering_stats_deltas.get('frameCount', 0) - else: - frame_count = rendering_stats_deltas.get('numFramesSentToScreen', 0) - - if not (frame_count > 0): - raise DidNotScrollException() - timeline = self._trace_result.AsTimelineModel() - render_process_marker = smoothness.FindTimelineMarkers( - timeline, smoothness.RENDER_PROCESS_MARKER) + render_process_marker = timeline.FindTimelineMarkers( + rendering_stats.RENDER_PROCESS_MARKER) compound_action = page_test.GetCompoundActionFromPage( page, self._action_name_to_run) timeline_marker_labels = GetTimelineMarkerLabelsFromAction(compound_action) # TODO(ernstm): remove try-except when the reference build was updated? try: - timeline_markers = smoothness.FindTimelineMarkers( - timeline, timeline_marker_labels) - except smoothness.TimelineMarkerMismatchException: + timeline_markers = timeline.FindTimelineMarkers(timeline_marker_labels) + except MarkerMismatchError: timeline_markers = render_process_marker - benchmark_stats = RenderingStats(render_process_marker, - timeline_markers, - rendering_stats_deltas, - self._metrics.is_using_gpu_benchmarking) - smoothness.CalcResults(benchmark_stats, results) + stats = rendering_stats.RenderingStats( + render_process_marker, timeline_markers) + + if not stats.frame_times: + raise NotEnoughFramesError() + + smoothness_metric = smoothness.SmoothnessMetric(stats) + smoothness_metric.AddResults(tab, results) if tab.browser.platform.IsRawDisplayFrameRateSupported(): for r in tab.browser.platform.GetRawDisplayFrameRateMeasurements(): if r.value is None: - raise MissingDisplayFrameRate(r.name) + raise MissingDisplayFrameRateError(r.name) results.Add(r.name, r.unit, r.value) |