Index: tools/perf/measurements/smoothness_controller.py |
diff --git a/tools/perf/measurements/smoothness_controller.py b/tools/perf/measurements/smoothness_controller.py |
index 1aa1fd7c5de5470dd439dee903a3c65ab7709840..b95ca7fbaebc4f94995ae9d37dd732d855e07660 100644 |
--- a/tools/perf/measurements/smoothness_controller.py |
+++ b/tools/perf/measurements/smoothness_controller.py |
@@ -1,11 +1,8 @@ |
# Copyright 2014 The Chromium Authors. All rights reserved. |
# Use of this source code is governed by a BSD-style license that can be |
# found in the LICENSE file. |
-import sys |
- |
from telemetry.core.platform import tracing_category_filter |
from telemetry.core.platform import tracing_options |
-from telemetry.page import action_runner |
from telemetry.timeline.model import TimelineModel |
from telemetry.value import trace |
from telemetry.web_perf.metrics import smoothness |
@@ -13,7 +10,8 @@ from telemetry.web_perf import smooth_gesture_util |
from telemetry.web_perf import timeline_interaction_record as tir_module |
-RUN_SMOOTH_ACTIONS = 'RunSmoothAllActions' |
+class SmoothnessTestException(Exception): |
+ pass |
class SmoothnessController(object): |
@@ -22,9 +20,8 @@ class SmoothnessController(object): |
self._trace_data = None |
self._interaction = None |
self._surface_flinger_trace_data = None |
- self._auto_issuing_marker = auto_issuing_marker |
- def SetUp(self, page, tab): |
+ def Start(self, page, tab): |
# FIXME: Remove webkit.console when blink.console lands in chromium and |
# the ref builds are updated. crbug.com/386847 |
custom_categories = ['webkit.console', 'blink.console', 'benchmark'] |
@@ -37,18 +34,7 @@ class SmoothnessController(object): |
options.enable_platform_display_trace = True |
tab.browser.platform.tracing_controller.Start(options, category_filter, 60) |
- def Start(self, tab): |
- # Start the smooth marker for all smooth actions. |
- runner = action_runner.ActionRunner(tab) |
- if self._auto_issuing_marker: |
- self._interaction = runner.CreateInteraction( |
- RUN_SMOOTH_ACTIONS) |
- self._interaction.Begin() |
- |
def Stop(self, tab): |
- # End the smooth marker for all smooth actions. |
- if self._auto_issuing_marker: |
- self._interaction.End() |
self._trace_data = tab.browser.platform.tracing_controller.Stop() |
self._timeline_model = TimelineModel(self._trace_data) |
@@ -60,35 +46,35 @@ class SmoothnessController(object): |
results.current_page, self._trace_data)) |
renderer_thread = self._timeline_model.GetRendererThreadFromTabId( |
tab.id) |
- run_smooth_actions_record = None |
smooth_records = [] |
for event in renderer_thread.async_slices: |
if not tir_module.IsTimelineInteractionRecord(event.name): |
continue |
r = tir_module.TimelineInteractionRecord.FromAsyncEvent(event) |
- if r.label == RUN_SMOOTH_ACTIONS: |
- assert run_smooth_actions_record is None, ( |
- 'SmoothnessController cannot issue more than 1 %s record' % |
- RUN_SMOOTH_ACTIONS) |
- run_smooth_actions_record = r |
- else: |
- smooth_records.append( |
- smooth_gesture_util.GetAdjustedInteractionIfContainGesture( |
- self._timeline_model, r)) |
+ smooth_records.append( |
+ smooth_gesture_util.GetAdjustedInteractionIfContainGesture( |
+ self._timeline_model, r)) |
# If there is no other smooth records, we make measurements on time range |
# marked smoothness_controller itself. |
# TODO(nednguyen): when crbug.com/239179 is marked fixed, makes sure that |
# page sets are responsible for issueing the markers themselves. |
if len(smooth_records) == 0: |
- if run_smooth_actions_record is None: |
- sys.stderr.write('Raw tracing data:\n') |
- self._trace_data.Serialize(sys.stderr) |
- sys.stderr.write('\n') |
- raise Exception('SmoothnessController failed to issue markers for the ' |
- 'whole interaction.') |
- else: |
- smooth_records = [run_smooth_actions_record] |
+ raise SmoothnessTestException('Page failed to issue any markers.') |
+ |
+ # Check to make sure all smooth records have same label and repeatable if |
+ # there are more than one. |
+ need_repeatable_flag = len(smooth_records) > 1 |
+ record_label = smooth_records[0].label |
+ for r in smooth_records: |
+ if r.label != record_label: |
+ raise SmoothnessTestException( |
+ 'SmoothController does not support multiple interactions with ' |
+ 'different label.') |
+ if need_repeatable_flag and not r.repeatable: |
+ raise SmoothnessTestException( |
+ 'If there are more than one interaction record, each interaction ' |
+ 'must has repeatable flag.') |
# Create an interaction_record for this legacy measurement. Since we don't |
# wrap the results that are sent to smoothness metric, the label will |