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 | |
49 def _AddV8MetricsToResults(self, process, results): | 45 def _AddV8MetricsToResults(self, process, results): |
50 if process is None: | 46 if process is None: |
51 return | 47 return |
52 | 48 |
53 for thread in process.threads.values(): | 49 for thread in process.threads.values(): |
54 if thread.name != self._RENDERER_MAIN_THREAD: | 50 if thread.name != self._RENDERER_MAIN_THREAD: |
55 continue | 51 continue |
56 | 52 |
57 self._AddV8EventStatsToResults(thread, results) | 53 self._AddV8EventStatsToResults(thread, results) |
58 self._AddCpuTimeStatsToResults(thread, results) | 54 self._AddCpuTimeStatsToResults(thread, results) |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 self.idle_task_overrun_duration = 0.0 | 183 self.idle_task_overrun_duration = 0.0 |
188 | 184 |
189 @property | 185 @property |
190 def thread_duration_outside_idle(self): | 186 def thread_duration_outside_idle(self): |
191 return self.thread_duration - self.thread_duration_inside_idle | 187 return self.thread_duration - self.thread_duration_inside_idle |
192 | 188 |
193 @property | 189 @property |
194 def percentage_thread_duration_during_idle(self): | 190 def percentage_thread_duration_during_idle(self): |
195 return statistics.DivideIfPossibleOrZero( | 191 return statistics.DivideIfPossibleOrZero( |
196 100 * self.thread_duration_inside_idle, self.thread_duration) | 192 100 * self.thread_duration_inside_idle, self.thread_duration) |
OLD | NEW |