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 | 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.timeline.model import TimelineModel | 7 from telemetry.timeline.model import TimelineModel |
8 from telemetry.page import page_test | 8 from telemetry.page import page_test |
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 22 matching lines...) Expand all Loading... |
33 for category in _CATEGORIES: | 33 for category in _CATEGORIES: |
34 category_filter.AddIncludedCategory(category) | 34 category_filter.AddIncludedCategory(category) |
35 | 35 |
36 options = tracing_options.TracingOptions() | 36 options = tracing_options.TracingOptions() |
37 options.enable_chrome_trace = True | 37 options.enable_chrome_trace = True |
38 | 38 |
39 tab.browser.platform.tracing_controller.Start( | 39 tab.browser.platform.tracing_controller.Start( |
40 options, category_filter, self._TIME_OUT_IN_SECONDS) | 40 options, category_filter, self._TIME_OUT_IN_SECONDS) |
41 | 41 |
42 def DidRunActions(self, page, tab): | 42 def DidRunActions(self, page, tab): |
43 timeline_data = tab.browser.platform.tracing_controller.Stop() | 43 trace_data = tab.browser.platform.tracing_controller.Stop() |
44 timeline_model = TimelineModel(timeline_data=timeline_data) | 44 timeline_model = TimelineModel(trace_data) |
45 self._renderer_thread = timeline_model.GetRendererThreadFromTabId(tab.id) | 45 self._renderer_thread = timeline_model.GetRendererThreadFromTabId(tab.id) |
46 | 46 |
47 def ValidateAndMeasurePage(self, page, tab, results): | 47 def ValidateAndMeasurePage(self, page, tab, results): |
48 tasks = TaskExecutionTime.GetTasks(self._renderer_thread.parent) | 48 tasks = TaskExecutionTime.GetTasks(self._renderer_thread.parent) |
49 | 49 |
50 sorted_tasks = sorted(tasks, | 50 sorted_tasks = sorted(tasks, |
51 key=lambda slice: slice.median_self_duration, reverse=True) | 51 key=lambda slice: slice.median_self_duration, reverse=True) |
52 | 52 |
53 for task in sorted_tasks[:self.GetExpectedResultCount()]: | 53 for task in sorted_tasks[:self.GetExpectedResultCount()]: |
54 results.AddValue(scalar.ScalarValue( | 54 results.AddValue(scalar.ScalarValue( |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 if key in dictionary: | 117 if key in dictionary: |
118 dictionary[key].Update( | 118 dictionary[key].Update( |
119 self_duration, total_duration, depth, parent) | 119 self_duration, total_duration, depth, parent) |
120 else: | 120 else: |
121 dictionary[key] = SliceData( | 121 dictionary[key] = SliceData( |
122 key, self_duration, total_duration, depth, parent) | 122 key, self_duration, total_duration, depth, parent) |
123 | 123 |
124 # Process sub slices recursively | 124 # Process sub slices recursively |
125 for sub_slice in task_slice.sub_slices: | 125 for sub_slice in task_slice.sub_slices: |
126 ProcessTasksForSlice(dictionary, sub_slice, depth + 1, parent) | 126 ProcessTasksForSlice(dictionary, sub_slice, depth + 1, parent) |
OLD | NEW |