OLD | NEW |
1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 | 4 |
5 from telemetry.core.platform import tracing_category_filter | 5 from telemetry.core.platform import tracing_category_filter |
6 from telemetry.core.platform import tracing_options | 6 from telemetry.core.platform import tracing_options |
7 from telemetry.page import page_test | 7 from telemetry.page import page_test |
8 from telemetry.timeline.model import TimelineModel | 8 from telemetry.timeline.model import TimelineModel |
9 from telemetry.util import statistics | 9 from telemetry.util import statistics |
10 from telemetry.value import scalar | 10 from telemetry.value import scalar |
(...skipping 24 matching lines...) Expand all Loading... |
35 | 35 |
36 tab.browser.platform.tracing_controller.Start( | 36 tab.browser.platform.tracing_controller.Start( |
37 options, category_filter, self._TIME_OUT_IN_SECONDS) | 37 options, category_filter, self._TIME_OUT_IN_SECONDS) |
38 | 38 |
39 def ValidateAndMeasurePage(self, page, tab, results): | 39 def ValidateAndMeasurePage(self, page, tab, results): |
40 trace_data = tab.browser.platform.tracing_controller.Stop() | 40 trace_data = tab.browser.platform.tracing_controller.Stop() |
41 timeline_model = TimelineModel(trace_data) | 41 timeline_model = TimelineModel(trace_data) |
42 renderer_process = timeline_model.GetRendererProcessFromTabId(tab.id) | 42 renderer_process = timeline_model.GetRendererProcessFromTabId(tab.id) |
43 self._AddV8MetricsToResults(renderer_process, results) | 43 self._AddV8MetricsToResults(renderer_process, results) |
44 | 44 |
| 45 def CleanUpAfterPage(self, page, tab): |
| 46 if tab.browser.platform.tracing_controller.is_tracing_running: |
| 47 tab.browser.platform.tracing_controller.Stop() |
| 48 |
45 def _AddV8MetricsToResults(self, process, results): | 49 def _AddV8MetricsToResults(self, process, results): |
46 if process is None: | 50 if process is None: |
47 return | 51 return |
48 | 52 |
49 for thread in process.threads.values(): | 53 for thread in process.threads.values(): |
50 if thread.name != self._RENDERER_MAIN_THREAD: | 54 if thread.name != self._RENDERER_MAIN_THREAD: |
51 continue | 55 continue |
52 | 56 |
53 self._AddV8EventStatsToResults(thread, results) | 57 self._AddV8EventStatsToResults(thread, results) |
54 self._AddCpuTimeStatsToResults(thread, results) | 58 self._AddCpuTimeStatsToResults(thread, results) |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 self.idle_task_overrun_duration = 0.0 | 187 self.idle_task_overrun_duration = 0.0 |
184 | 188 |
185 @property | 189 @property |
186 def thread_duration_outside_idle(self): | 190 def thread_duration_outside_idle(self): |
187 return self.thread_duration - self.thread_duration_inside_idle | 191 return self.thread_duration - self.thread_duration_inside_idle |
188 | 192 |
189 @property | 193 @property |
190 def percentage_thread_duration_during_idle(self): | 194 def percentage_thread_duration_during_idle(self): |
191 return statistics.DivideIfPossibleOrZero( | 195 return statistics.DivideIfPossibleOrZero( |
192 100 * self.thread_duration_inside_idle, self.thread_duration) | 196 100 * self.thread_duration_inside_idle, self.thread_duration) |
OLD | NEW |