| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 import sys | 4 import sys |
| 5 | 5 |
| 6 from measurements import smooth_gesture_util | 6 from measurements import smooth_gesture_util |
| 7 from telemetry.timeline.model import TimelineModel | 7 from telemetry.timeline.model import TimelineModel |
| 8 from telemetry.page import page_measurement | 8 from telemetry.page import page_measurement |
| 9 from telemetry.page.actions import action_runner | 9 from telemetry.page.actions import action_runner |
| 10 from telemetry.web_perf import timeline_interaction_record as tir_module | 10 from telemetry.web_perf import timeline_interaction_record as tir_module |
| 11 from telemetry.web_perf.metrics import smoothness | 11 from telemetry.web_perf.metrics import smoothness |
| 12 | 12 |
| 13 | 13 |
| 14 RUN_SMOOTH_ACTIONS = 'RunSmoothAllActions' | 14 RUN_SMOOTH_ACTIONS = 'RunSmoothAllActions' |
| 15 | 15 |
| 16 | 16 |
| 17 class MissingDisplayFrameRateError(page_measurement.MeasurementFailure): | 17 class MissingDisplayFrameRateError(page_measurement.MeasurementFailure): |
| 18 def __init__(self, name): | 18 def __init__(self, name): |
| 19 super(MissingDisplayFrameRateError, self).__init__( | 19 super(MissingDisplayFrameRateError, self).__init__( |
| 20 'Missing display frame rate metrics: ' + name) | 20 'Missing display frame rate metrics: ' + name) |
| 21 | 21 |
| 22 class SmoothnessController(object): | 22 class SmoothnessController(object): |
| 23 def __init__(self): | 23 def __init__(self): |
| 24 self._timeline_model = None | 24 self._timeline_model = None |
| 25 self._tracing_timeline_data = None | 25 self._tracing_timeline_data = None |
| 26 self._interaction = None | 26 self._interaction = None |
| 27 | 27 |
| 28 def Start(self, page, tab): | 28 def Start(self, page, tab): |
| 29 custom_categories = ['webkit.console', 'benchmark'] | 29 custom_categories = ['webkit.console', 'blink.console', 'benchmark'] |
| 30 custom_categories += page.GetSyntheticDelayCategories() | 30 custom_categories += page.GetSyntheticDelayCategories() |
| 31 tab.browser.StartTracing(','.join(custom_categories), 60) | 31 tab.browser.StartTracing(','.join(custom_categories), 60) |
| 32 if tab.browser.platform.IsRawDisplayFrameRateSupported(): | 32 if tab.browser.platform.IsRawDisplayFrameRateSupported(): |
| 33 tab.browser.platform.StartRawDisplayFrameRateMeasurement() | 33 tab.browser.platform.StartRawDisplayFrameRateMeasurement() |
| 34 # Start the smooth marker for all smooth actions. | 34 # Start the smooth marker for all smooth actions. |
| 35 runner = action_runner.ActionRunner(tab) | 35 runner = action_runner.ActionRunner(tab) |
| 36 self._interaction = runner.BeginInteraction( | 36 self._interaction = runner.BeginInteraction( |
| 37 RUN_SMOOTH_ACTIONS, is_smooth=True) | 37 RUN_SMOOTH_ACTIONS, is_smooth=True) |
| 38 | 38 |
| 39 def Stop(self, tab): | 39 def Stop(self, tab): |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 for r in tab.browser.platform.GetRawDisplayFrameRateMeasurements(): | 93 for r in tab.browser.platform.GetRawDisplayFrameRateMeasurements(): |
| 94 if r.value is None: | 94 if r.value is None: |
| 95 raise MissingDisplayFrameRateError(r.name) | 95 raise MissingDisplayFrameRateError(r.name) |
| 96 results.Add(r.name, r.unit, r.value) | 96 results.Add(r.name, r.unit, r.value) |
| 97 | 97 |
| 98 def CleanUp(self, tab): | 98 def CleanUp(self, tab): |
| 99 if tab.browser.platform.IsRawDisplayFrameRateSupported(): | 99 if tab.browser.platform.IsRawDisplayFrameRateSupported(): |
| 100 tab.browser.platform.StopRawDisplayFrameRateMeasurement() | 100 tab.browser.platform.StopRawDisplayFrameRateMeasurement() |
| 101 if tab.browser.is_tracing_running: | 101 if tab.browser.is_tracing_running: |
| 102 tab.browser.StopTracing() | 102 tab.browser.StopTracing() |
| OLD | NEW |