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.page import page_test | 5 from telemetry.page import page_test |
6 from telemetry.timeline.model import TimelineModel | 6 from telemetry.timeline.model import TimelineModel |
7 from telemetry.timeline import tracing_config | 7 from telemetry.timeline import tracing_config |
8 from telemetry.util import statistics | 8 from telemetry.util import statistics |
9 from telemetry.value import scalar | 9 from telemetry.value import scalar |
10 | 10 |
11 | 11 |
12 class V8GCTimes(page_test.PageTest): | 12 class V8GCTimes(page_test.PageTest): |
13 | 13 |
14 _TIME_OUT_IN_SECONDS = 60 | 14 _TIME_OUT_IN_SECONDS = 60 |
15 _CATEGORIES = ['blink.console', | 15 _CATEGORIES = ['blink.console', |
16 'renderer.scheduler', | 16 'renderer.scheduler', |
17 'v8', | 17 'v8', |
18 'webkit.console'] | 18 'webkit.console'] |
19 _RENDERER_MAIN_THREAD = 'CrRendererMain' | 19 _RENDERER_MAIN_THREAD = 'CrRendererMain' |
20 _IDLE_TASK_PARENT = 'SingleThreadIdleTaskRunner::RunTask' | 20 _IDLE_TASK_PARENT = 'SingleThreadIdleTaskRunner::RunTask' |
21 | 21 |
22 def __init__(self): | 22 def __init__(self): |
23 super(V8GCTimes, self).__init__() | 23 super(V8GCTimes, self).__init__() |
24 | 24 |
25 def WillNavigateToPage(self, page, tab): | 25 def WillNavigateToPage(self, page, tab): |
| 26 del page # unused |
26 config = tracing_config.TracingConfig() | 27 config = tracing_config.TracingConfig() |
27 for category in self._CATEGORIES: | 28 for category in self._CATEGORIES: |
28 config.tracing_category_filter.AddIncludedCategory(category) | 29 config.tracing_category_filter.AddIncludedCategory(category) |
29 config.enable_chrome_trace = True | 30 config.enable_chrome_trace = True |
30 tab.browser.platform.tracing_controller.StartTracing( | 31 tab.browser.platform.tracing_controller.StartTracing( |
31 config, self._TIME_OUT_IN_SECONDS) | 32 config, self._TIME_OUT_IN_SECONDS) |
32 | 33 |
33 def ValidateAndMeasurePage(self, page, tab, results): | 34 def ValidateAndMeasurePage(self, page, tab, results): |
| 35 del page # unused |
34 trace_data = tab.browser.platform.tracing_controller.StopTracing() | 36 trace_data = tab.browser.platform.tracing_controller.StopTracing() |
35 timeline_model = TimelineModel(trace_data) | 37 timeline_model = TimelineModel(trace_data) |
36 renderer_process = timeline_model.GetRendererProcessFromTabId(tab.id) | 38 renderer_process = timeline_model.GetRendererProcessFromTabId(tab.id) |
37 self._AddV8MetricsToResults(renderer_process, results) | 39 self._AddV8MetricsToResults(renderer_process, results) |
38 | 40 |
39 def DidRunPage(self, platform): | 41 def DidRunPage(self, platform): |
40 if platform.tracing_controller.is_tracing_running: | 42 if platform.tracing_controller.is_tracing_running: |
41 platform.tracing_controller.StopTracing() | 43 platform.tracing_controller.StopTracing() |
42 | 44 |
43 def _AddV8MetricsToResults(self, process, results): | 45 def _AddV8MetricsToResults(self, process, results): |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 self.count = 0 | 231 self.count = 0 |
230 | 232 |
231 @property | 233 @property |
232 def thread_duration_outside_idle(self): | 234 def thread_duration_outside_idle(self): |
233 return self.thread_duration - self.thread_duration_inside_idle | 235 return self.thread_duration - self.thread_duration_inside_idle |
234 | 236 |
235 @property | 237 @property |
236 def percentage_thread_duration_during_idle(self): | 238 def percentage_thread_duration_during_idle(self): |
237 return statistics.DivideIfPossibleOrZero( | 239 return statistics.DivideIfPossibleOrZero( |
238 100 * self.thread_duration_inside_idle, self.thread_duration) | 240 100 * self.thread_duration_inside_idle, self.thread_duration) |
OLD | NEW |