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 # FIXME: Remove webkit.console when blink.console lands in chromium and |
| 30 # the ref builds are updated. crbug.com/386847 |
| 31 custom_categories = ['webkit.console', 'blink.console', 'benchmark'] |
30 custom_categories += page.GetSyntheticDelayCategories() | 32 custom_categories += page.GetSyntheticDelayCategories() |
31 tab.browser.StartTracing(','.join(custom_categories), 60) | 33 tab.browser.StartTracing(','.join(custom_categories), 60) |
32 if tab.browser.platform.IsRawDisplayFrameRateSupported(): | 34 if tab.browser.platform.IsRawDisplayFrameRateSupported(): |
33 tab.browser.platform.StartRawDisplayFrameRateMeasurement() | 35 tab.browser.platform.StartRawDisplayFrameRateMeasurement() |
34 # Start the smooth marker for all smooth actions. | 36 # Start the smooth marker for all smooth actions. |
35 runner = action_runner.ActionRunner(tab) | 37 runner = action_runner.ActionRunner(tab) |
36 self._interaction = runner.BeginInteraction( | 38 self._interaction = runner.BeginInteraction( |
37 RUN_SMOOTH_ACTIONS, is_smooth=True) | 39 RUN_SMOOTH_ACTIONS, is_smooth=True) |
38 | 40 |
39 def Stop(self, tab): | 41 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(): | 95 for r in tab.browser.platform.GetRawDisplayFrameRateMeasurements(): |
94 if r.value is None: | 96 if r.value is None: |
95 raise MissingDisplayFrameRateError(r.name) | 97 raise MissingDisplayFrameRateError(r.name) |
96 results.Add(r.name, r.unit, r.value) | 98 results.Add(r.name, r.unit, r.value) |
97 | 99 |
98 def CleanUp(self, tab): | 100 def CleanUp(self, tab): |
99 if tab.browser.platform.IsRawDisplayFrameRateSupported(): | 101 if tab.browser.platform.IsRawDisplayFrameRateSupported(): |
100 tab.browser.platform.StopRawDisplayFrameRateMeasurement() | 102 tab.browser.platform.StopRawDisplayFrameRateMeasurement() |
101 if tab.browser.is_tracing_running: | 103 if tab.browser.is_tracing_running: |
102 tab.browser.StopTracing() | 104 tab.browser.StopTracing() |
OLD | NEW |