Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(702)

Side by Side Diff: telemetry/telemetry/benchmark.py

Issue 3001873002: [Telemetry] Add CanRunOnPlatform to story_runner and benchmark class. (Closed)
Patch Set: unit tests Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | telemetry/telemetry/benchmark_unittest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 optparse 5 import optparse
6 6
7 from py_utils import class_util 7 from py_utils import class_util
8 from telemetry import decorators 8 from telemetry import decorators
9 from telemetry.internal import story_runner 9 from telemetry.internal import story_runner
10 from telemetry.internal.util import command_line 10 from telemetry.internal.util import command_line
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 56
57 A benchmark packages a measurement and a PageSet together. 57 A benchmark packages a measurement and a PageSet together.
58 Benchmarks default to using TBM unless you override the value of 58 Benchmarks default to using TBM unless you override the value of
59 Benchmark.test, or override the CreatePageTest method. 59 Benchmark.test, or override the CreatePageTest method.
60 60
61 New benchmarks should override CreateStorySet. 61 New benchmarks should override CreateStorySet.
62 """ 62 """
63 options = {} 63 options = {}
64 page_set = None 64 page_set = None
65 test = timeline_based_measurement.TimelineBasedMeasurement 65 test = timeline_based_measurement.TimelineBasedMeasurement
66 SUPPORTED_PLATFORMS = [expectations.ALL]
66 67
67 def __init__(self, max_failures=None): 68 def __init__(self, max_failures=None):
68 """Creates a new Benchmark. 69 """Creates a new Benchmark.
69 70
70 Args: 71 Args:
71 max_failures: The number of story run's failures before bailing 72 max_failures: The number of story run's failures before bailing
72 from executing subsequent page runs. If None, we never bail. 73 from executing subsequent page runs. If None, we never bail.
73 """ 74 """
74 self._expectations = None 75 self._expectations = None
75 self._max_failures = max_failures 76 self._max_failures = max_failures
76 # TODO: There should be an assertion here that checks that only one of 77 # TODO: There should be an assertion here that checks that only one of
77 # the following is true: 78 # the following is true:
78 # * It's a TBM benchmark, with CreateCoreTimelineBasedMeasurementOptions 79 # * It's a TBM benchmark, with CreateCoreTimelineBasedMeasurementOptions
79 # defined. 80 # defined.
80 # * It's a legacy benchmark, with either CreatePageTest defined or 81 # * It's a legacy benchmark, with either CreatePageTest defined or
81 # Benchmark.test set. 82 # Benchmark.test set.
82 # See https://github.com/catapult-project/catapult/issues/3708 83 # See https://github.com/catapult-project/catapult/issues/3708
83 84
84 85
86 def CanRunOnPlatform(self, platform, finder_options):
nednguyen 2017/08/18 23:46:53 If this is not supposed to be overridden, can you
rnephew (Reviews Here) 2017/08/21 16:30:32 Done.
87 for p in self.SUPPORTED_PLATFORMS:
88 # This is reusing StoryExpectation code, so it is a bit unintuitive. We
89 # are trying to detect the opposite of the usual case in StoryExpectations
90 # so we want to return True when ShouldDisable returns true, even though
91 # we do not want to disable.
92 if p.ShouldDisable(platform, finder_options):
93 return True
94 return False
95
85 # pylint: disable=unused-argument 96 # pylint: disable=unused-argument
86 @classmethod 97 @classmethod
87 def ShouldDisable(cls, possible_browser): 98 def ShouldDisable(cls, possible_browser):
88 """Override this method to disable a benchmark under specific conditions. 99 """Override this method to disable a benchmark under specific conditions.
89 100
90 Supports logic too complex for simple Enabled and Disabled decorators. 101 Supports logic too complex for simple Enabled and Disabled decorators.
91 Decorators are still respected in cases where this function returns False. 102 Decorators are still respected in cases where this function returns False.
92 """ 103 """
93 return False 104 return False
94 105
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 """ 358 """
348 return expectations.StoryExpectations() 359 return expectations.StoryExpectations()
349 360
350 361
351 def AddCommandLineArgs(parser): 362 def AddCommandLineArgs(parser):
352 story_runner.AddCommandLineArgs(parser) 363 story_runner.AddCommandLineArgs(parser)
353 364
354 365
355 def ProcessCommandLineArgs(parser, args): 366 def ProcessCommandLineArgs(parser, args):
356 story_runner.ProcessCommandLineArgs(parser, args) 367 story_runner.ProcessCommandLineArgs(parser, args)
OLDNEW
« no previous file with comments | « no previous file | telemetry/telemetry/benchmark_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698