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.value import list_of_scalar_values | 10 from telemetry.value import list_of_scalar_values |
11 from telemetry.value import scalar | 11 from telemetry.value import scalar |
12 from telemetry.web_perf import timeline_interaction_record as tir_module | 12 from telemetry.web_perf import timeline_interaction_record as tir_module |
13 from telemetry.web_perf.metrics import smoothness | 13 from telemetry.web_perf.metrics import smoothness |
14 | 14 |
15 | 15 |
16 RUN_SMOOTH_ACTIONS = 'RunSmoothAllActions' | 16 RUN_SMOOTH_ACTIONS = 'RunSmoothAllActions' |
17 | 17 |
18 | 18 |
19 class MissingDisplayFrameRateError(page_measurement.MeasurementFailure): | 19 class MissingDisplayFrameRateError(page_measurement.MeasurementFailure): |
20 def __init__(self, name): | 20 def __init__(self, name): |
21 super(MissingDisplayFrameRateError, self).__init__( | 21 super(MissingDisplayFrameRateError, self).__init__( |
22 'Missing display frame rate metrics: ' + name) | 22 'Missing display frame rate metrics: ' + name) |
23 | 23 |
24 class SmoothnessController(object): | 24 class SmoothnessController(object): |
25 def __init__(self): | 25 def __init__(self): |
26 self._timeline_model = None | 26 self._timeline_model = None |
27 self._tracing_timeline_data = None | 27 self._tracing_timeline_data = None |
28 self._interaction = None | 28 self._interaction = None |
29 | 29 |
30 def Start(self, page, tab): | 30 def SetUp(self, page, tab): |
31 # FIXME: Remove webkit.console when blink.console lands in chromium and | 31 # FIXME: Remove webkit.console when blink.console lands in chromium and |
32 # the ref builds are updated. crbug.com/386847 | 32 # the ref builds are updated. crbug.com/386847 |
33 custom_categories = ['webkit.console', 'blink.console', 'benchmark'] | 33 custom_categories = ['webkit.console', 'blink.console', 'benchmark'] |
34 custom_categories += page.GetSyntheticDelayCategories() | 34 custom_categories += page.GetSyntheticDelayCategories() |
35 tab.browser.StartTracing(','.join(custom_categories), 60) | 35 tab.browser.StartTracing(','.join(custom_categories), 60) |
36 if tab.browser.platform.IsRawDisplayFrameRateSupported(): | 36 if tab.browser.platform.IsRawDisplayFrameRateSupported(): |
37 tab.browser.platform.StartRawDisplayFrameRateMeasurement() | 37 tab.browser.platform.StartRawDisplayFrameRateMeasurement() |
| 38 |
| 39 def Start(self, tab): |
38 # Start the smooth marker for all smooth actions. | 40 # Start the smooth marker for all smooth actions. |
39 runner = action_runner.ActionRunner(tab) | 41 runner = action_runner.ActionRunner(tab) |
40 self._interaction = runner.BeginInteraction( | 42 self._interaction = runner.BeginInteraction( |
41 RUN_SMOOTH_ACTIONS, is_smooth=True) | 43 RUN_SMOOTH_ACTIONS, is_smooth=True) |
42 | 44 |
43 def Stop(self, tab): | 45 def Stop(self, tab): |
44 # End the smooth marker for all smooth actions. | 46 # End the smooth marker for all smooth actions. |
45 self._interaction.End() | 47 self._interaction.End() |
46 # Stop tracing for smoothness metric. | 48 # Stop tracing for smoothness metric. |
47 if tab.browser.platform.IsRawDisplayFrameRateSupported(): | 49 if tab.browser.platform.IsRawDisplayFrameRateSupported(): |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 results.current_page, r.name, r.unit, r.value)) | 104 results.current_page, r.name, r.unit, r.value)) |
103 else: | 105 else: |
104 results.AddValue(scalar.ScalarValue( | 106 results.AddValue(scalar.ScalarValue( |
105 results.current_page, r.name, r.unit, r.value)) | 107 results.current_page, r.name, r.unit, r.value)) |
106 | 108 |
107 def CleanUp(self, tab): | 109 def CleanUp(self, tab): |
108 if tab.browser.platform.IsRawDisplayFrameRateSupported(): | 110 if tab.browser.platform.IsRawDisplayFrameRateSupported(): |
109 tab.browser.platform.StopRawDisplayFrameRateMeasurement() | 111 tab.browser.platform.StopRawDisplayFrameRateMeasurement() |
110 if tab.browser.is_tracing_running: | 112 if tab.browser.is_tracing_running: |
111 tab.browser.StopTracing() | 113 tab.browser.StopTracing() |
OLD | NEW |