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 logging | 5 import logging |
6 import optparse | 6 import optparse |
7 import os | 7 import os |
8 import sys | 8 import sys |
9 import time | 9 import time |
10 | 10 |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 | 273 |
274 def RunBenchmark(benchmark, finder_options): | 274 def RunBenchmark(benchmark, finder_options): |
275 """Run this test with the given options. | 275 """Run this test with the given options. |
276 | 276 |
277 Returns: | 277 Returns: |
278 The number of failure values (up to 254) or 255 if there is an uncaught | 278 The number of failure values (up to 254) or 255 if there is an uncaught |
279 exception. | 279 exception. |
280 """ | 280 """ |
281 benchmark.CustomizeBrowserOptions(finder_options.browser_options) | 281 benchmark.CustomizeBrowserOptions(finder_options.browser_options) |
282 | 282 |
| 283 benchmark_metadata = benchmark.GetMetadata() |
283 possible_browser = browser_finder.FindBrowser(finder_options) | 284 possible_browser = browser_finder.FindBrowser(finder_options) |
284 if possible_browser and benchmark.ShouldDisable(possible_browser): | 285 if possible_browser and benchmark.ShouldDisable(possible_browser): |
285 logging.warning('%s is disabled on the selected browser', benchmark.Name()) | 286 logging.warning('%s is disabled on the selected browser', benchmark.Name()) |
286 if finder_options.run_disabled_tests: | 287 if finder_options.run_disabled_tests: |
287 logging.warning( | 288 logging.warning( |
288 'Running benchmark anyway due to: --also-run-disabled-tests') | 289 'Running benchmark anyway due to: --also-run-disabled-tests') |
289 else: | 290 else: |
290 logging.warning( | 291 logging.warning( |
291 'Try --also-run-disabled-tests to force the benchmark to run.') | 292 'Try --also-run-disabled-tests to force the benchmark to run.') |
| 293 # If chartjson is specified, this will print a dict indicating the |
| 294 # benchmark name and disabled state. crrev.com/2265423005 will update |
| 295 # this return value once this logic is plumbed through the recipe. |
| 296 with results_options.CreateResults(benchmark_metadata, finder_options, |
| 297 benchmark.ValueCanBeAddedPredicate) as results: |
| 298 results.PrintDisabledSummary() |
292 return 1 | 299 return 1 |
293 | 300 |
294 pt = benchmark.CreatePageTest(finder_options) | 301 pt = benchmark.CreatePageTest(finder_options) |
295 pt.__name__ = benchmark.__class__.__name__ | 302 pt.__name__ = benchmark.__class__.__name__ |
296 | 303 |
297 disabled_attr_name = decorators.DisabledAttributeName(benchmark) | 304 disabled_attr_name = decorators.DisabledAttributeName(benchmark) |
298 # pylint: disable=protected-access | 305 # pylint: disable=protected-access |
299 pt._disabled_strings = getattr(benchmark, disabled_attr_name, set()) | 306 pt._disabled_strings = getattr(benchmark, disabled_attr_name, set()) |
300 if hasattr(benchmark, '_enabled_strings'): | 307 if hasattr(benchmark, '_enabled_strings'): |
301 # pylint: disable=protected-access | 308 # pylint: disable=protected-access |
302 pt._enabled_strings = benchmark._enabled_strings | 309 pt._enabled_strings = benchmark._enabled_strings |
303 | 310 |
304 stories = benchmark.CreateStorySet(finder_options) | 311 stories = benchmark.CreateStorySet(finder_options) |
305 if isinstance(pt, legacy_page_test.LegacyPageTest): | 312 if isinstance(pt, legacy_page_test.LegacyPageTest): |
306 if any(not isinstance(p, page.Page) for p in stories.stories): | 313 if any(not isinstance(p, page.Page) for p in stories.stories): |
307 raise Exception( | 314 raise Exception( |
308 'PageTest must be used with StorySet containing only ' | 315 'PageTest must be used with StorySet containing only ' |
309 'telemetry.page.Page stories.') | 316 'telemetry.page.Page stories.') |
310 | 317 |
311 should_tear_down_state_after_each_story_run = ( | 318 should_tear_down_state_after_each_story_run = ( |
312 benchmark.ShouldTearDownStateAfterEachStoryRun()) | 319 benchmark.ShouldTearDownStateAfterEachStoryRun()) |
313 # HACK: restarting shared state has huge overhead on cros (crbug.com/645329), | 320 # HACK: restarting shared state has huge overhead on cros (crbug.com/645329), |
314 # hence we default this to False when test is run against CrOS. | 321 # hence we default this to False when test is run against CrOS. |
315 # TODO(cros-team): figure out ways to remove this hack. | 322 # TODO(cros-team): figure out ways to remove this hack. |
316 if (possible_browser.platform.GetOSName() == 'chromeos' and | 323 if (possible_browser.platform.GetOSName() == 'chromeos' and |
317 not benchmark.IsShouldTearDownStateAfterEachStoryRunOverriden()): | 324 not benchmark.IsShouldTearDownStateAfterEachStoryRunOverriden()): |
318 should_tear_down_state_after_each_story_run = False | 325 should_tear_down_state_after_each_story_run = False |
319 | 326 |
320 benchmark_metadata = benchmark.GetMetadata() | 327 |
321 with results_options.CreateResults( | 328 with results_options.CreateResults( |
322 benchmark_metadata, finder_options, | 329 benchmark_metadata, finder_options, |
323 benchmark.ValueCanBeAddedPredicate) as results: | 330 benchmark.ValueCanBeAddedPredicate) as results: |
324 try: | 331 try: |
325 Run(pt, stories, finder_options, results, benchmark.max_failures, | 332 Run(pt, stories, finder_options, results, benchmark.max_failures, |
326 should_tear_down_state_after_each_story_run, | 333 should_tear_down_state_after_each_story_run, |
327 benchmark.ShouldTearDownStateAfterEachStorySetRun()) | 334 benchmark.ShouldTearDownStateAfterEachStorySetRun()) |
328 return_code = min(254, len(results.failures)) | 335 return_code = min(254, len(results.failures)) |
329 except Exception: | 336 except Exception: |
330 exception_formatter.PrintFormattedException() | 337 exception_formatter.PrintFormattedException() |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 logging.warning('Device is thermally throttled before running ' | 426 logging.warning('Device is thermally throttled before running ' |
420 'performance tests, results will vary.') | 427 'performance tests, results will vary.') |
421 | 428 |
422 | 429 |
423 def _CheckThermalThrottling(platform): | 430 def _CheckThermalThrottling(platform): |
424 if not platform.CanMonitorThermalThrottling(): | 431 if not platform.CanMonitorThermalThrottling(): |
425 return | 432 return |
426 if platform.HasBeenThermallyThrottled(): | 433 if platform.HasBeenThermallyThrottled(): |
427 logging.warning('Device has been thermally throttled during ' | 434 logging.warning('Device has been thermally throttled during ' |
428 'performance tests, results will vary.') | 435 'performance tests, results will vary.') |
OLD | NEW |