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 import os | 5 import os |
6 | 6 |
7 from telemetry.core.platform import tracing_category_filter | 7 from telemetry.core.platform import tracing_category_filter |
8 from telemetry.core.platform import tracing_options | 8 from telemetry.core.platform import tracing_options |
9 from telemetry.page import action_runner | 9 from telemetry.page import action_runner |
10 from telemetry.page import page_test | 10 from telemetry.page import page_test |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 | 127 |
128 gc_time = 0 | 128 gc_time = 0 |
129 for key in values: | 129 for key in values: |
130 gc_time += sum(values[key]) | 130 gc_time += sum(values[key]) |
131 results.AddValue(scalar.ScalarValue(page, 'oilpan_gc', unit, gc_time)) | 131 results.AddValue(scalar.ScalarValue(page, 'oilpan_gc', unit, gc_time)) |
132 | 132 |
133 | 133 |
134 class _OilpanGCTimesBase(page_test.PageTest): | 134 class _OilpanGCTimesBase(page_test.PageTest): |
135 def __init__(self, action_name=''): | 135 def __init__(self, action_name=''): |
136 super(_OilpanGCTimesBase, self).__init__(action_name) | 136 super(_OilpanGCTimesBase, self).__init__(action_name) |
137 self._timeline_model = None | |
138 | 137 |
139 def WillNavigateToPage(self, page, tab): | 138 def WillNavigateToPage(self, page, tab): |
140 # FIXME: Remove webkit.console when blink.console lands in chromium and | 139 # FIXME: Remove webkit.console when blink.console lands in chromium and |
141 # the ref builds are updated. crbug.com/386847 | 140 # the ref builds are updated. crbug.com/386847 |
142 categories = ['webkit.console', 'blink.console', 'blink_gc'] | 141 categories = ['webkit.console', 'blink.console', 'blink_gc'] |
143 category_filter = tracing_category_filter.TracingCategoryFilter() | 142 category_filter = tracing_category_filter.TracingCategoryFilter() |
144 for c in categories: | 143 for c in categories: |
145 category_filter.AddIncludedCategory(c) | 144 category_filter.AddIncludedCategory(c) |
146 options = tracing_options.TracingOptions() | 145 options = tracing_options.TracingOptions() |
147 options.enable_chrome_trace = True | 146 options.enable_chrome_trace = True |
148 tab.browser.platform.tracing_controller.Start(options, category_filter, | 147 tab.browser.platform.tracing_controller.Start(options, category_filter, |
149 timeout=1000) | 148 timeout=1000) |
150 | 149 |
151 def DidRunActions(self, page, tab): | 150 def ValidateAndMeasurePage(self, page, tab, results): |
152 timeline_data = tab.browser.platform.tracing_controller.Stop() | 151 timeline_data = tab.browser.platform.tracing_controller.Stop() |
153 self._timeline_model = TimelineModel(timeline_data) | 152 timeline_model = TimelineModel(timeline_data) |
154 | 153 threads = timeline_model.GetAllThreads() |
155 def ValidateAndMeasurePage(self, page, tab, results): | |
156 threads = self._timeline_model.GetAllThreads() | |
157 for thread in threads: | 154 for thread in threads: |
158 if thread.name == _CR_RENDERER_MAIN: | 155 if thread.name == _CR_RENDERER_MAIN: |
159 _AddTracingResults(thread, results) | 156 _AddTracingResults(thread, results) |
160 | 157 |
161 def CleanUpAfterPage(self, page, tab): | 158 def CleanUpAfterPage(self, page, tab): |
162 if tab.browser.platform.tracing_controller.is_tracing_running: | 159 if tab.browser.platform.tracing_controller.is_tracing_running: |
163 tab.browser.platform.tracing_controller.Stop() | 160 tab.browser.platform.tracing_controller.Stop() |
164 | 161 |
165 | 162 |
166 class OilpanGCTimesForSmoothness(_OilpanGCTimesBase): | 163 class OilpanGCTimesForSmoothness(_OilpanGCTimesBase): |
167 def __init__(self): | 164 def __init__(self): |
168 super(OilpanGCTimesForSmoothness, self).__init__() | 165 super(OilpanGCTimesForSmoothness, self).__init__() |
169 self._interaction = None | 166 self._interaction = None |
170 | 167 |
171 def DidNavigateToPage(self, page, tab): | 168 def DidNavigateToPage(self, page, tab): |
172 runner = action_runner.ActionRunner(tab) | 169 runner = action_runner.ActionRunner(tab) |
173 self._interaction = runner.CreateInteraction(_RUN_SMOOTH_ACTIONS) | 170 self._interaction = runner.CreateInteraction(_RUN_SMOOTH_ACTIONS) |
174 self._interaction.Begin() | 171 self._interaction.Begin() |
175 | 172 |
176 def DidRunActions(self, page, tab): | 173 def ValidateAndMeasurePage(self, page, tab, results): |
177 self._interaction.End() | 174 self._interaction.End() |
178 super(OilpanGCTimesForSmoothness, self).DidRunActions(page, tab) | 175 super(OilpanGCTimesForSmoothness, self).ValidateAndMeasurePage( |
| 176 page, tab, results) |
179 | 177 |
180 | 178 |
181 class OilpanGCTimesForBlinkPerf(_OilpanGCTimesBase): | 179 class OilpanGCTimesForBlinkPerf(_OilpanGCTimesBase): |
182 def __init__(self): | 180 def __init__(self): |
183 super(OilpanGCTimesForBlinkPerf, self).__init__() | 181 super(OilpanGCTimesForBlinkPerf, self).__init__() |
184 with open(os.path.join(os.path.dirname(__file__), '..', 'benchmarks', | 182 with open(os.path.join(os.path.dirname(__file__), '..', 'benchmarks', |
185 'blink_perf.js'), 'r') as f: | 183 'blink_perf.js'), 'r') as f: |
186 self._blink_perf_js = f.read() | 184 self._blink_perf_js = f.read() |
187 | 185 |
188 def WillNavigateToPage(self, page, tab): | 186 def WillNavigateToPage(self, page, tab): |
189 page.script_to_evaluate_on_commit = self._blink_perf_js | 187 page.script_to_evaluate_on_commit = self._blink_perf_js |
190 super(OilpanGCTimesForBlinkPerf, self).WillNavigateToPage(page, tab) | 188 super(OilpanGCTimesForBlinkPerf, self).WillNavigateToPage(page, tab) |
191 | 189 |
192 def DidRunActions(self, page, tab): | 190 def ValidateAndMeasurePage(self, page, tab, results): |
193 tab.WaitForJavaScriptExpression('testRunner.isDone', 600) | 191 tab.WaitForJavaScriptExpression('testRunner.isDone', 600) |
194 super(OilpanGCTimesForBlinkPerf, self).DidRunActions(page, tab) | 192 super(OilpanGCTimesForBlinkPerf, self).ValidateAndMeasurePage( |
| 193 page, tab, results) |
195 | 194 |
196 | 195 |
197 class OilpanGCTimesForInternals(OilpanGCTimesForBlinkPerf): | 196 class OilpanGCTimesForInternals(OilpanGCTimesForBlinkPerf): |
198 def __init__(self): | 197 def __init__(self): |
199 super(OilpanGCTimesForInternals, self).__init__() | 198 super(OilpanGCTimesForInternals, self).__init__() |
200 | 199 |
201 @classmethod | 200 @classmethod |
202 def CustomizeBrowserOptions(cls, options): | 201 def CustomizeBrowserOptions(cls, options): |
203 # 'expose-internals-for-testing' can be enabled on content shell. | 202 # 'expose-internals-for-testing' can be enabled on content shell. |
204 assert 'content-shell' in options.browser_type | 203 assert 'content-shell' in options.browser_type |
205 options.AppendExtraBrowserArgs(['--expose-internals-for-testing', | 204 options.AppendExtraBrowserArgs(['--expose-internals-for-testing', |
206 '--js-flags=--expose-gc']) | 205 '--js-flags=--expose-gc']) |
OLD | NEW |