| 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.core.platform import tracing_category_filter | 7 from telemetry.core.platform import tracing_category_filter |
| 8 from telemetry.core.platform import tracing_options | 8 from telemetry.core.platform import tracing_options |
| 9 from telemetry.timeline.model import TimelineModel | 9 from telemetry.timeline.model import TimelineModel |
| 10 from telemetry.page import page_test | 10 from telemetry.page import page_test |
| 11 from telemetry.page.actions import action_runner | 11 from telemetry.page.actions import action_runner |
| 12 from telemetry.value import list_of_scalar_values | 12 from telemetry.value import list_of_scalar_values |
| 13 from telemetry.value import scalar | 13 from telemetry.value import scalar |
| 14 from telemetry.value import trace |
| 14 from telemetry.web_perf import timeline_interaction_record as tir_module | 15 from telemetry.web_perf import timeline_interaction_record as tir_module |
| 15 from telemetry.web_perf.metrics import smoothness | 16 from telemetry.web_perf.metrics import smoothness |
| 16 | 17 |
| 17 | 18 |
| 18 RUN_SMOOTH_ACTIONS = 'RunSmoothAllActions' | 19 RUN_SMOOTH_ACTIONS = 'RunSmoothAllActions' |
| 19 | 20 |
| 20 # Descriptions for results from platform.GetRawDisplayFrameRateMeasurements(). | 21 # Descriptions for results from platform.GetRawDisplayFrameRateMeasurements(). |
| 21 DESCRIPTIONS = { | 22 DESCRIPTIONS = { |
| 22 'avg_surface_fps': 'Average frames per second as measured by the ' | 23 'avg_surface_fps': 'Average frames per second as measured by the ' |
| 23 'platform\'s SurfaceFlinger.' | 24 'platform\'s SurfaceFlinger.' |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 if tab.browser.platform.IsRawDisplayFrameRateSupported(): | 63 if tab.browser.platform.IsRawDisplayFrameRateSupported(): |
| 63 tab.browser.platform.StopRawDisplayFrameRateMeasurement() | 64 tab.browser.platform.StopRawDisplayFrameRateMeasurement() |
| 64 self._tracing_timeline_data = tab.browser.platform.tracing_controller.Stop() | 65 self._tracing_timeline_data = tab.browser.platform.tracing_controller.Stop() |
| 65 self._timeline_model = TimelineModel( | 66 self._timeline_model = TimelineModel( |
| 66 timeline_data=self._tracing_timeline_data) | 67 timeline_data=self._tracing_timeline_data) |
| 67 | 68 |
| 68 def AddResults(self, tab, results): | 69 def AddResults(self, tab, results): |
| 69 # Add results of smoothness metric. This computes the smoothness metric for | 70 # Add results of smoothness metric. This computes the smoothness metric for |
| 70 # the time ranges of gestures, if there is at least one, else the the time | 71 # the time ranges of gestures, if there is at least one, else the the time |
| 71 # ranges from the first action to the last action. | 72 # ranges from the first action to the last action. |
| 72 | 73 results.AddValue(trace.TraceValue( |
| 74 results.current_page, 'trace', self._tracing_timeline_data)) |
| 73 renderer_thread = self._timeline_model.GetRendererThreadFromTabId( | 75 renderer_thread = self._timeline_model.GetRendererThreadFromTabId( |
| 74 tab.id) | 76 tab.id) |
| 75 run_smooth_actions_record = None | 77 run_smooth_actions_record = None |
| 76 smooth_records = [] | 78 smooth_records = [] |
| 77 for event in renderer_thread.async_slices: | 79 for event in renderer_thread.async_slices: |
| 78 if not tir_module.IsTimelineInteractionRecord(event.name): | 80 if not tir_module.IsTimelineInteractionRecord(event.name): |
| 79 continue | 81 continue |
| 80 r = tir_module.TimelineInteractionRecord.FromAsyncEvent(event) | 82 r = tir_module.TimelineInteractionRecord.FromAsyncEvent(event) |
| 81 if r.label == RUN_SMOOTH_ACTIONS: | 83 if r.label == RUN_SMOOTH_ACTIONS: |
| 82 assert run_smooth_actions_record is None, ( | 84 assert run_smooth_actions_record is None, ( |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 else: | 121 else: |
| 120 results.AddValue(scalar.ScalarValue( | 122 results.AddValue(scalar.ScalarValue( |
| 121 results.current_page, r.name, r.unit, r.value, | 123 results.current_page, r.name, r.unit, r.value, |
| 122 description=DESCRIPTIONS.get(r.name))) | 124 description=DESCRIPTIONS.get(r.name))) |
| 123 | 125 |
| 124 def CleanUp(self, tab): | 126 def CleanUp(self, tab): |
| 125 if tab.browser.platform.IsRawDisplayFrameRateSupported(): | 127 if tab.browser.platform.IsRawDisplayFrameRateSupported(): |
| 126 tab.browser.platform.StopRawDisplayFrameRateMeasurement() | 128 tab.browser.platform.StopRawDisplayFrameRateMeasurement() |
| 127 if tab.browser.platform.tracing_controller.is_tracing_running: | 129 if tab.browser.platform.tracing_controller.is_tracing_running: |
| 128 tab.browser.platform.tracing_controller.Stop() | 130 tab.browser.platform.tracing_controller.Stop() |
| OLD | NEW |