| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 import codecs | 4 import codecs |
| 5 import logging | 5 import logging |
| 6 import os | 6 import os |
| 7 import time | 7 import time |
| 8 import traceback | 8 import traceback |
| 9 import urlparse | 9 import urlparse |
| 10 import random | 10 import random |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 if not state.browser: | 135 if not state.browser: |
| 136 self._SetupBrowser(state, test, possible_browser, | 136 self._SetupBrowser(state, test, possible_browser, |
| 137 credentials_path, page.archive_path) | 137 credentials_path, page.archive_path) |
| 138 if not state.tab: | 138 if not state.tab: |
| 139 if len(state.browser.tabs) == 0: | 139 if len(state.browser.tabs) == 0: |
| 140 state.browser.tabs.New() | 140 state.browser.tabs.New() |
| 141 state.tab = state.browser.tabs[0] | 141 state.tab = state.browser.tabs[0] |
| 142 if options.trace_dir: | 142 if options.trace_dir: |
| 143 self._SetupTracingTab(state) | 143 self._SetupTracingTab(state) |
| 144 | 144 |
| 145 self._WaitForThermalThrottlingIfNeeded(state.browser.platform) |
| 146 |
| 145 try: | 147 try: |
| 146 self._RunPage(options, page, state.tab, test, results) | 148 self._RunPage(options, page, state.tab, test, results) |
| 147 except exceptions.TabCrashException: | 149 except exceptions.TabCrashException: |
| 148 stdout = '' | 150 stdout = '' |
| 149 if not options.show_stdout: | 151 if not options.show_stdout: |
| 150 stdout = state.browser.GetStandardOutput() | 152 stdout = state.browser.GetStandardOutput() |
| 151 stdout = (('\nStandard Output:\n') + | 153 stdout = (('\nStandard Output:\n') + |
| 152 ('*' * 80) + | 154 ('*' * 80) + |
| 153 '\n\t' + stdout.replace('\n', '\n\t') + '\n' + | 155 '\n\t' + stdout.replace('\n', '\n\t') + '\n' + |
| 154 ('*' * 80)) | 156 ('*' * 80)) |
| 155 logging.warning('Tab crashed: %s%s', page.url, stdout) | 157 logging.warning('Tab crashed: %s%s', page.url, stdout) |
| 156 state.Close() | 158 state.Close() |
| 157 | 159 |
| 160 self._CheckThermalThrottling(state.browser.platform) |
| 161 |
| 158 if options.trace_dir: | 162 if options.trace_dir: |
| 159 self._EndTracing(state, options, page) | 163 self._EndTracing(state, options, page) |
| 160 | 164 |
| 161 if test.needs_browser_restart_after_each_run: | 165 if test.needs_browser_restart_after_each_run: |
| 162 state.Close() | 166 state.Close() |
| 163 | 167 |
| 164 break | 168 break |
| 165 except exceptions.BrowserGoneException: | 169 except exceptions.BrowserGoneException: |
| 166 logging.warning('Lost connection to browser. Retrying.') | 170 logging.warning('Lost connection to browser. Retrying.') |
| 167 state.Close() | 171 state.Close() |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 | 311 |
| 308 def _CleanUpPage(self, page, tab, page_state): # pylint: disable=R0201 | 312 def _CleanUpPage(self, page, tab, page_state): # pylint: disable=R0201 |
| 309 if page.credentials and page_state.did_login: | 313 if page.credentials and page_state.did_login: |
| 310 tab.browser.credentials.LoginNoLongerNeeded(tab, page.credentials) | 314 tab.browser.credentials.LoginNoLongerNeeded(tab, page.credentials) |
| 311 try: | 315 try: |
| 312 tab.EvaluateJavaScript("""window.chrome && chrome.benchmarking && | 316 tab.EvaluateJavaScript("""window.chrome && chrome.benchmarking && |
| 313 chrome.benchmarking.closeConnections()""") | 317 chrome.benchmarking.closeConnections()""") |
| 314 except Exception: | 318 except Exception: |
| 315 pass | 319 pass |
| 316 | 320 |
| 321 def _WaitForThermalThrottlingIfNeeded(self, platform): |
| 322 if not platform.CanMonitorThermalThrottling(): |
| 323 return |
| 324 thermal_throttling_retry = 0 |
| 325 while (platform.IsThermallyThrottled() and |
| 326 thermal_throttling_retry < 3): |
| 327 logging.warning('Thermally throttled, waiting (%d)...', |
| 328 thermal_throttling_retry) |
| 329 thermal_throttling_retry += 1 |
| 330 time.sleep(thermal_throttling_retry * 2) |
| 331 |
| 332 if platform.IsThermallyThrottled(): |
| 333 logging.error('Device is thermally throttled before running ' |
| 334 'performance tests, results will vary.') |
| 335 |
| 336 def _CheckThermalThrottling(self, platform): |
| 337 if not platform.CanMonitorThermalThrottling(): |
| 338 return |
| 339 if platform.HasBeenThermallyThrottled(): |
| 340 logging.error('Device has been thermally throttled during ' |
| 341 'performance tests, results will vary.') |
| 342 |
| 317 @staticmethod | 343 @staticmethod |
| 318 def AddCommandLineOptions(parser): | 344 def AddCommandLineOptions(parser): |
| 319 page_filter_module.PageFilter.AddCommandLineOptions(parser) | 345 page_filter_module.PageFilter.AddCommandLineOptions(parser) |
| OLD | NEW |