| 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.timeline.model import TimelineModel | 7 from telemetry.core.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 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 tab.browser.platform.StopRawDisplayFrameRateMeasurement() | 44 tab.browser.platform.StopRawDisplayFrameRateMeasurement() |
| 45 self._tracing_timeline_data = tab.browser.StopTracing() | 45 self._tracing_timeline_data = tab.browser.StopTracing() |
| 46 self._timeline_model = TimelineModel( | 46 self._timeline_model = TimelineModel( |
| 47 timeline_data=self._tracing_timeline_data) | 47 timeline_data=self._tracing_timeline_data) |
| 48 | 48 |
| 49 def AddResults(self, tab, results): | 49 def AddResults(self, tab, results): |
| 50 # Add results of smoothness metric. This computes the smoothness metric for | 50 # Add results of smoothness metric. This computes the smoothness metric for |
| 51 # the time ranges of gestures, if there is at least one, else the the time | 51 # the time ranges of gestures, if there is at least one, else the the time |
| 52 # ranges from the first action to the last action. | 52 # ranges from the first action to the last action. |
| 53 | 53 |
| 54 renderer_thread = self._timeline_model.GetRendererThreadFromTab(tab) | 54 renderer_thread = self._timeline_model.GetRendererThreadFromTabId( |
| 55 tab.id) |
| 55 run_smooth_actions_record = None | 56 run_smooth_actions_record = None |
| 56 smooth_records = [] | 57 smooth_records = [] |
| 57 for event in renderer_thread.async_slices: | 58 for event in renderer_thread.async_slices: |
| 58 if not tir_module.IsTimelineInteractionRecord(event.name): | 59 if not tir_module.IsTimelineInteractionRecord(event.name): |
| 59 continue | 60 continue |
| 60 r = tir_module.TimelineInteractionRecord.FromAsyncEvent(event) | 61 r = tir_module.TimelineInteractionRecord.FromAsyncEvent(event) |
| 61 if r.logical_name == RUN_SMOOTH_ACTIONS: | 62 if r.logical_name == RUN_SMOOTH_ACTIONS: |
| 62 assert run_smooth_actions_record is None, ( | 63 assert run_smooth_actions_record is None, ( |
| 63 'SmoothnessController cannot issue more than 1 %s record' % | 64 'SmoothnessController cannot issue more than 1 %s record' % |
| 64 RUN_SMOOTH_ACTIONS) | 65 RUN_SMOOTH_ACTIONS) |
| (...skipping 27 matching lines...) Expand all Loading... |
| 92 for r in tab.browser.platform.GetRawDisplayFrameRateMeasurements(): | 93 for r in tab.browser.platform.GetRawDisplayFrameRateMeasurements(): |
| 93 if r.value is None: | 94 if r.value is None: |
| 94 raise MissingDisplayFrameRateError(r.name) | 95 raise MissingDisplayFrameRateError(r.name) |
| 95 results.Add(r.name, r.unit, r.value) | 96 results.Add(r.name, r.unit, r.value) |
| 96 | 97 |
| 97 def CleanUp(self, tab): | 98 def CleanUp(self, tab): |
| 98 if tab.browser.platform.IsRawDisplayFrameRateSupported(): | 99 if tab.browser.platform.IsRawDisplayFrameRateSupported(): |
| 99 tab.browser.platform.StopRawDisplayFrameRateMeasurement() | 100 tab.browser.platform.StopRawDisplayFrameRateMeasurement() |
| 100 if tab.browser.is_tracing_running: | 101 if tab.browser.is_tracing_running: |
| 101 tab.browser.StopTracing() | 102 tab.browser.StopTracing() |
| OLD | NEW |