def RunMeasurement(self, measurement, ps, expectations=test_expectations.TestExpectations(), options=None): """Runs a measurement against a pageset, returning the rows its outputs.""" if options is None: options = options_for_unittests.GetCopy() assert options temp_parser = options.CreateParser() user_story_runner.AddCommandLineArgs(temp_parser) defaults = temp_parser.get_default_values() for k, v in defaults.__dict__.items(): if hasattr(options, k): continue setattr(options, k, v) measurement.CustomizeBrowserOptions(options.browser_options) options.output_file = None options.output_formats = ['none'] options.suppress_gtest_report = True options.output_trace_tag = None user_story_runner.ProcessCommandLineArgs(temp_parser, options) results = results_options.CreateResults(EmptyMetadataForTest(), options) user_story_runner.Run(measurement, ps, expectations, options, results) return results
def _GetOptionForUnittest(): options = options_for_unittests.GetCopy() options.output_formats = ['none'] options.suppress_gtest_report = True parser = options.CreateParser() user_story_runner.AddCommandLineArgs(parser) options.MergeDefaultValues(parser.get_default_values()) user_story_runner.ProcessCommandLineArgs(parser, options) return options
def SetUpCycler(self, page_repeat=1, pageset_repeat=10, cold_load_percent=50, record_v8_object_stats=False, report_speed_index=False, setup_memory_module=False): cycler = page_cycler.PageCycler( page_repeat=page_repeat, pageset_repeat=pageset_repeat, cold_load_percent=cold_load_percent, record_v8_object_stats=record_v8_object_stats, report_speed_index=report_speed_index) options = browser_options.BrowserFinderOptions() options.browser_options.platform = FakePlatform() parser = options.CreateParser() user_story_runner.AddCommandLineArgs(parser) args = [ '--page-repeat=%i' % page_repeat, '--pageset-repeat=%i' % pageset_repeat ] parser.parse_args(args) user_story_runner.ProcessCommandLineArgs(parser, options) cycler.CustomizeBrowserOptions(options.browser_options) if setup_memory_module: # Mock out memory metrics; the real ones require a real browser. mock_memory_metric = MockMemoryMetric() mock_memory_module = simple_mock.MockObject() mock_memory_module.ExpectCall('MemoryMetric').WithArgs( simple_mock.DONT_CARE).WillReturn(mock_memory_metric) real_memory_module = page_cycler.memory try: page_cycler.memory = mock_memory_module browser = FakeBrowser() cycler.WillStartBrowser(options.browser_options.platform) cycler.DidStartBrowser(browser) finally: page_cycler.memory = real_memory_module return cycler
def ProcessCommandLineArgs(parser, args): user_story_runner.ProcessCommandLineArgs(parser, args) if not args.profile_type_to_generate: parser.error("Must specify --profile-type-to-generate option.") profile_creators = _DiscoverProfileCreatorClasses().keys() if args.profile_type_to_generate not in profile_creators: legal_profile_creators = '|'.join(profile_creators) parser.error("Invalid profile type, legal values are: %s." % legal_profile_creators) if not args.browser_type: parser.error("Must specify --browser option.") if not args.output_dir: parser.error("Must specify --output-dir option.") if args.browser_options.dont_override_profile: parser.error("Can't use existing profile when generating profile.")
def _ProcessCommandLineArgs(self): user_story_runner.ProcessCommandLineArgs(self._parser, self._options) if self._benchmark is not None: self._benchmark.ProcessCommandLineArgs(self._parser, self._options)
def ProcessCommandLineArgs(parser, args): user_story_runner.ProcessCommandLineArgs(parser, args)
def SetUpUserStoryRunnerArguments(options): parser = options.CreateParser() user_story_runner.AddCommandLineArgs(parser) options.MergeDefaultValues(parser.get_default_values()) user_story_runner.ProcessCommandLineArgs(parser, options)