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 subprocess | 8 import subprocess |
9 import sys | 9 import sys |
10 import time | 10 import time |
11 | 11 |
12 import py_utils | 12 import py_utils |
13 from py_utils import cloud_storage # pylint: disable=import-error | 13 from py_utils import cloud_storage # pylint: disable=import-error |
14 | 14 |
15 from telemetry.core import exceptions | 15 from telemetry.core import exceptions |
16 from telemetry import decorators | 16 from telemetry import decorators |
17 from telemetry.internal.actions import page_action | 17 from telemetry.internal.actions import page_action |
18 from telemetry.internal.browser import browser_finder | 18 from telemetry.internal.browser import browser_finder |
19 from telemetry.internal.results import results_options | 19 from telemetry.internal.results import results_options |
20 from telemetry.internal.util import exception_formatter | 20 from telemetry.internal.util import exception_formatter |
21 from telemetry import page | 21 from telemetry import page |
22 from telemetry.page import legacy_page_test | 22 from telemetry.page import legacy_page_test |
23 from telemetry import story as story_module | 23 from telemetry import story as story_module |
24 from telemetry.util import wpr_modes | 24 from telemetry.util import wpr_modes |
25 from telemetry.value import failure | 25 from telemetry.value import failure |
26 from telemetry.value import skip | 26 from telemetry.value import skip |
27 from telemetry.value import scalar | |
27 from telemetry.web_perf import story_test | 28 from telemetry.web_perf import story_test |
28 | 29 |
29 | 30 |
30 class ArchiveError(Exception): | 31 class ArchiveError(Exception): |
31 pass | 32 pass |
32 | 33 |
33 | 34 |
34 def AddCommandLineArgs(parser): | 35 def AddCommandLineArgs(parser): |
35 story_module.StoryFilter.AddCommandLineArgs(parser) | 36 story_module.StoryFilter.AddCommandLineArgs(parser) |
36 results_options.AddResultsOptions(parser) | 37 results_options.AddResultsOptions(parser) |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
294 story.display_name) | 295 story.display_name) |
295 | 296 |
296 | 297 |
297 def RunBenchmark(benchmark, finder_options): | 298 def RunBenchmark(benchmark, finder_options): |
298 """Run this test with the given options. | 299 """Run this test with the given options. |
299 | 300 |
300 Returns: | 301 Returns: |
301 The number of failure values (up to 254) or 255 if there is an uncaught | 302 The number of failure values (up to 254) or 255 if there is an uncaught |
302 exception. | 303 exception. |
303 """ | 304 """ |
305 start = time.time() | |
304 benchmark.CustomizeBrowserOptions(finder_options.browser_options) | 306 benchmark.CustomizeBrowserOptions(finder_options.browser_options) |
305 | 307 |
306 benchmark_metadata = benchmark.GetMetadata() | 308 benchmark_metadata = benchmark.GetMetadata() |
307 possible_browser = browser_finder.FindBrowser(finder_options) | 309 possible_browser = browser_finder.FindBrowser(finder_options) |
308 if not possible_browser: | 310 if not possible_browser: |
309 print ('Cannot find browser of type %s. To list out all ' | 311 print ('Cannot find browser of type %s. To list out all ' |
310 'available browsers, rerun your command with ' | 312 'available browsers, rerun your command with ' |
311 '--browser=list' % finder_options.browser_options.browser_type) | 313 '--browser=list' % finder_options.browser_options.browser_type) |
312 return 1 | 314 return 1 |
313 if (possible_browser and | 315 if (possible_browser and |
314 not decorators.IsBenchmarkEnabled(benchmark, possible_browser)): | 316 not decorators.IsBenchmarkEnabled(benchmark, possible_browser)): |
315 print '%s is disabled on the selected browser' % benchmark.Name() | 317 print '%s is disabled on the selected browser' % benchmark.Name() |
316 if finder_options.run_disabled_tests: | 318 if finder_options.run_disabled_tests: |
317 print 'Running benchmark anyway due to: --also-run-disabled-tests' | 319 print 'Running benchmark anyway due to: --also-run-disabled-tests' |
318 else: | 320 else: |
319 print 'Try --also-run-disabled-tests to force the benchmark to run.' | 321 print 'Try --also-run-disabled-tests to force the benchmark to run.' |
320 # If chartjson is specified, this will print a dict indicating the | 322 # If chartjson is specified, this will print a dict indicating the |
321 # benchmark name and disabled state. | 323 # benchmark name and disabled state. |
322 with results_options.CreateResults( | 324 with results_options.CreateResults( |
323 benchmark_metadata, finder_options, | 325 benchmark_metadata, finder_options, |
324 benchmark.ValueCanBeAddedPredicate, benchmark_enabled=False | 326 benchmark.ValueCanBeAddedPredicate, benchmark_enabled=False |
325 ) as results: | 327 ) as results: |
326 results.PrintSummary() | 328 results.PrintSummary() |
327 # When a disabled benchmark is run we now want to return success since | 329 # When a disabled benchmark is run we now want to return success since |
328 # we are no longer filtering these out in the buildbot recipes. | 330 # we are no longer filtering these out in the buildbot recipes. |
329 return 0 | 331 return 17 |
nednguyen
2017/03/26 01:46:04
hmhh, this needs some unittest to avoid mistake in
martiniss
2017/03/26 03:58:51
Wow, I don't remember doing this at all. We defini
| |
330 | 332 |
331 pt = benchmark.CreatePageTest(finder_options) | 333 pt = benchmark.CreatePageTest(finder_options) |
332 pt.__name__ = benchmark.__class__.__name__ | 334 pt.__name__ = benchmark.__class__.__name__ |
333 | 335 |
334 disabled_attr_name = decorators.DisabledAttributeName(benchmark) | 336 disabled_attr_name = decorators.DisabledAttributeName(benchmark) |
335 # pylint: disable=protected-access | 337 # pylint: disable=protected-access |
336 pt._disabled_strings = getattr(benchmark, disabled_attr_name, set()) | 338 pt._disabled_strings = getattr(benchmark, disabled_attr_name, set()) |
337 if hasattr(benchmark, '_enabled_strings'): | 339 if hasattr(benchmark, '_enabled_strings'): |
338 # pylint: disable=protected-access | 340 # pylint: disable=protected-access |
339 pt._enabled_strings = benchmark._enabled_strings | 341 pt._enabled_strings = benchmark._enabled_strings |
(...skipping 28 matching lines...) Expand all Loading... | |
368 return_code = 255 | 370 return_code = 255 |
369 | 371 |
370 try: | 372 try: |
371 if finder_options.upload_results: | 373 if finder_options.upload_results: |
372 bucket = finder_options.upload_bucket | 374 bucket = finder_options.upload_bucket |
373 if bucket in cloud_storage.BUCKET_ALIASES: | 375 if bucket in cloud_storage.BUCKET_ALIASES: |
374 bucket = cloud_storage.BUCKET_ALIASES[bucket] | 376 bucket = cloud_storage.BUCKET_ALIASES[bucket] |
375 results.UploadTraceFilesToCloud(bucket) | 377 results.UploadTraceFilesToCloud(bucket) |
376 results.UploadProfilingFilesToCloud(bucket) | 378 results.UploadProfilingFilesToCloud(bucket) |
377 finally: | 379 finally: |
380 duration = time.time() - start | |
381 results.AddSummaryValue(scalar.ScalarValue( | |
382 None, 'BenchmarkDuration', 'minutes', duration / 60.0)) | |
378 results.PrintSummary() | 383 results.PrintSummary() |
379 return return_code | 384 return return_code |
380 | 385 |
381 | 386 |
382 def _UpdateAndCheckArchives(archive_data_file, wpr_archive_info, | 387 def _UpdateAndCheckArchives(archive_data_file, wpr_archive_info, |
383 filtered_stories): | 388 filtered_stories): |
384 """Verifies that all stories are local or have WPR archives. | 389 """Verifies that all stories are local or have WPR archives. |
385 | 390 |
386 Logs warnings and returns False if any are missing. | 391 Logs warnings and returns False if any are missing. |
387 """ | 392 """ |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
458 logging.warning('Device is thermally throttled before running ' | 463 logging.warning('Device is thermally throttled before running ' |
459 'performance tests, results will vary.') | 464 'performance tests, results will vary.') |
460 | 465 |
461 | 466 |
462 def _CheckThermalThrottling(platform): | 467 def _CheckThermalThrottling(platform): |
463 if not platform.CanMonitorThermalThrottling(): | 468 if not platform.CanMonitorThermalThrottling(): |
464 return | 469 return |
465 if platform.HasBeenThermallyThrottled(): | 470 if platform.HasBeenThermallyThrottled(): |
466 logging.warning('Device has been thermally throttled during ' | 471 logging.warning('Device has been thermally throttled during ' |
467 'performance tests, results will vary.') | 472 'performance tests, results will vary.') |
OLD | NEW |