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

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

Issue 1126443002: Move user_story.user_story_set to story.story_set (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update init file. Created 5 years, 7 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
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 logging 5 import logging
6 import optparse 6 import optparse
7 import os 7 import os
8 import shutil 8 import shutil
9 import sys 9 import sys
10 import zipfile 10 import zipfile
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 return self._rerun_options 51 return self._rerun_options
52 52
53 53
54 class Benchmark(command_line.Command): 54 class Benchmark(command_line.Command):
55 """Base class for a Telemetry benchmark. 55 """Base class for a Telemetry benchmark.
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 CreateUserStorySet. 61 New benchmarks should override CreateStorySet.
62 """ 62 """
63 options = {} 63 options = {}
64 test = timeline_based_measurement.TimelineBasedMeasurement 64 test = timeline_based_measurement.TimelineBasedMeasurement
65 65
66 def __init__(self, max_failures=None): 66 def __init__(self, max_failures=None):
67 """Creates a new Benchmark. 67 """Creates a new Benchmark.
68 68
69 Args: 69 Args:
70 max_failures: The number of user story run's failures before bailing 70 max_failures: The number of user story run's failures before bailing
71 from executing subsequent page runs. If None, we never bail. 71 from executing subsequent page runs. If None, we never bail.
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 pt.__name__ = self.__class__.__name__ 177 pt.__name__ = self.__class__.__name__
178 178
179 if hasattr(self, '_disabled_strings'): 179 if hasattr(self, '_disabled_strings'):
180 # pylint: disable=protected-access 180 # pylint: disable=protected-access
181 pt._disabled_strings = self._disabled_strings 181 pt._disabled_strings = self._disabled_strings
182 if hasattr(self, '_enabled_strings'): 182 if hasattr(self, '_enabled_strings'):
183 # pylint: disable=protected-access 183 # pylint: disable=protected-access
184 pt._enabled_strings = self._enabled_strings 184 pt._enabled_strings = self._enabled_strings
185 185
186 expectations = self.CreateExpectations() 186 expectations = self.CreateExpectations()
187 us = self.CreateUserStorySet(finder_options) 187 us = self.CreateStorySet(finder_options)
188 if isinstance(pt, page_test.PageTest): 188 if isinstance(pt, page_test.PageTest):
189 if any(not isinstance(p, page.Page) for p in us.user_stories): 189 if any(not isinstance(p, page.Page) for p in us.user_stories):
190 raise Exception( 190 raise Exception(
191 'PageTest must be used with UserStorySet containing only ' 191 'PageTest must be used with StorySet containing only '
192 'telemetry.page.Page user stories.') 192 'telemetry.page.Page user stories.')
193 193
194 self._DownloadGeneratedProfileArchive(finder_options) 194 self._DownloadGeneratedProfileArchive(finder_options)
195 195
196 benchmark_metadata = self.GetMetadata() 196 benchmark_metadata = self.GetMetadata()
197 with results_options.CreateResults( 197 with results_options.CreateResults(
198 benchmark_metadata, finder_options, 198 benchmark_metadata, finder_options,
199 self.ValueCanBeAddedPredicate) as results: 199 self.ValueCanBeAddedPredicate) as results:
200 try: 200 try:
201 story_runner.Run(pt, us, expectations, finder_options, results, 201 story_runner.Run(pt, us, expectations, finder_options, results,
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 320
321 By default, it will create a page set from the this test's page_set 321 By default, it will create a page set from the this test's page_set
322 attribute. Override to generate a custom page set. 322 attribute. Override to generate a custom page set.
323 """ 323 """
324 if not hasattr(self, 'page_set'): 324 if not hasattr(self, 'page_set'):
325 raise NotImplementedError('This test has no "page_set" attribute.') 325 raise NotImplementedError('This test has no "page_set" attribute.')
326 if not issubclass(self.page_set, page_set.PageSet): 326 if not issubclass(self.page_set, page_set.PageSet):
327 raise TypeError('"%s" is not a PageSet.' % self.page_set.__name__) 327 raise TypeError('"%s" is not a PageSet.' % self.page_set.__name__)
328 return self.page_set() 328 return self.page_set()
329 329
330 def CreateUserStorySet(self, options): 330 def CreateStorySet(self, options):
331 return self.CreatePageSet(options) 331 return self.CreatePageSet(options)
332 332
333 @classmethod 333 @classmethod
334 def CreateExpectations(cls): 334 def CreateExpectations(cls):
335 """Get the expectations this test will run with. 335 """Get the expectations this test will run with.
336 336
337 By default, it will create an empty expectations set. Override to generate 337 By default, it will create an empty expectations set. Override to generate
338 custom expectations. 338 custom expectations.
339 """ 339 """
340 return test_expectations.TestExpectations() 340 return test_expectations.TestExpectations()
341 341
342 342
343 def AddCommandLineArgs(parser): 343 def AddCommandLineArgs(parser):
344 story_runner.AddCommandLineArgs(parser) 344 story_runner.AddCommandLineArgs(parser)
345 345
346 346
347 def ProcessCommandLineArgs(parser, args): 347 def ProcessCommandLineArgs(parser, args):
348 story_runner.ProcessCommandLineArgs(parser, args) 348 story_runner.ProcessCommandLineArgs(parser, args)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698