def ValidateAndMeasurePage(self, _, tab, results): self._results = results tab.browser.platform.tracing_controller.telemetry_info = ( results.telemetry_info) trace_result = tab.browser.platform.tracing_controller.StopTracing() # TODO(charliea): This is part of a three-sided Chromium/Telemetry patch # where we're changing the return type of StopTracing from a TraceValue to a # (TraceValue, nonfatal_exception_list) tuple. Once the tuple return value # lands in Chromium, the non-tuple logic should be deleted. if isinstance(trace_result, tuple): trace_result = trace_result[0] trace_value = trace.TraceValue( results.current_page, trace_result, file_path=results.telemetry_info.trace_local_path, remote_path=results.telemetry_info.trace_remote_path, upload_bucket=results.telemetry_info.upload_bucket, cloud_url=results.telemetry_info.trace_remote_url) results.AddValue(trace_value) model = model_module.TimelineModel(trace_result) renderer_thread = model.GetFirstRendererThread(tab.id) records = _CollectRecordsFromRendererThreads(model, renderer_thread) thread_times_metric = timeline.ThreadTimesTimelineMetric() thread_times_metric.AddResults(model, renderer_thread, records, results) rendering_util.AddTBMv2RenderingMetrics( trace_value, results, import_experimental_metrics=True)
def testOverheadIsRemoved(self): model = model_module.TimelineModel() renderer_main = model.GetOrCreateProcess(1).GetOrCreateThread(2) renderer_main.name = 'CrRendererMain' # Create one frame swap. cc_main = model.GetOrCreateProcess(1).GetOrCreateThread(3) cc_main.name = 'Compositor' cc_main.BeginSlice('cc_cat', timeline.FrameTraceName, 10, 10) cc_main.EndSlice(11, 11) # [ X ] # [Overhead] overhead_category = timeline.OverheadTraceCategory overhead_name = timeline.OverheadTraceName renderer_main.BeginSlice('cat1', 'X', 10, 0) renderer_main.BeginSlice(overhead_category, overhead_name, 15, 5) renderer_main.EndSlice(16, 6) renderer_main.EndSlice(30, 10) model.FinalizeImport() # Include everything in an action-range. metric = timeline.ThreadTimesTimelineMetric() metric.details_to_report = timeline.ReportMainThreadOnly results = self.GetResults(metric, model, renderer_main.parent, [_GetInteractionRecord(10, 30)]) # Test a couple specific results. assert_results = { timeline.ThreadCpuTimeResultName('renderer_main'): 9.0, } for name, value in assert_results.iteritems(): results.AssertHasPageSpecificScalarValue(name, 'ms', value)
def WillRunActions(self, page, tab): self._metric = timeline.ThreadTimesTimelineMetric() if self.options.report_silk_results: self._metric.results_to_report = timeline.ReportSilkResults if self.options.report_silk_details: self._metric.details_to_report = timeline.ReportSilkDetails self._metric.Start(page, tab)
def testBasic(self): model = model_module.TimelineModel() renderer_main = model.GetOrCreateProcess(1).GetOrCreateThread(2) renderer_main.name = 'CrRendererMain' # Create two frame swaps (Results times should be divided by two) for # an interaction that lasts 20 milliseconds. cc_main = model.GetOrCreateProcess(1).GetOrCreateThread(3) cc_main.name = 'Compositor' cc_main.BeginSlice('cc_cat', timeline.FrameTraceName, 10, 10) cc_main.EndSlice(11, 11) cc_main.BeginSlice('cc_cat', timeline.FrameTraceName, 12, 12) cc_main.EndSlice(13, 13) # [ X ] [ Z ] # [ Y ] renderer_main.BeginSlice('cat1', 'X', 10, 0) renderer_main.BeginSlice('cat2', 'Y', 15, 5) renderer_main.EndSlice(16, 5.5) renderer_main.EndSlice(30, 19.5) renderer_main.BeginSlice('cat1', 'Z', 31, 20) renderer_main.BeginSlice('cat1', 'Z', 33, 21) model.FinalizeImport() # Exclude 'Z' using an action-range. metric = timeline.ThreadTimesTimelineMetric() metric.details_to_report = timeline.ReportMainThreadOnly results = self.GetResults(metric, model, renderer_main.parent, [_GetInteractionRecord(10, 30)]) # Test for the results we expect. main_thread = 'renderer_main' cc_thread = 'renderer_compositor' assert_results = [ (timeline.ThreadMeanFrameTimeResultName(cc_thread), 'ms', 10.0), (timeline.ThreadTasksResultName(main_thread, 'frame'), 'tasks', 0.5), (timeline.ThreadTasksResultName(main_thread, 'second'), 'tasks', 50.0), (timeline.ThreadTasksResultName(cc_thread, 'frame'), 'tasks', 1.0), (timeline.ThreadTasksResultName(cc_thread, 'second'), 'tasks', 100.0), (timeline.ThreadCpuTimeResultName(main_thread, 'frame'), 'ms', 9.75), (timeline.ThreadCpuTimeResultName(main_thread, 'second'), '%', 97.5), (timeline.ThreadCpuTimeResultName(cc_thread, 'frame'), 'ms', 1.0), (timeline.ThreadCpuTimeResultName(cc_thread, 'second'), '%', 10.0), (timeline.ThreadDetailResultName(main_thread, 'frame', 'cat1'), 'ms', 9.5), (timeline.ThreadDetailResultName(main_thread, 'second', 'cat1'), '%', 95.0), (timeline.ThreadDetailResultName(main_thread, 'frame', 'cat2'), 'ms', 0.5), (timeline.ThreadDetailResultName(main_thread, 'second', 'cat2'), '%', 5.0), (timeline.ThreadDetailResultName( main_thread, 'frame', 'idle'), 'ms', 0), (timeline.ThreadDetailResultName( main_thread, 'second', 'idle'), '%', 0) ] for name, unit, value in assert_results: results.AssertHasPageSpecificScalarValue(name, unit, value)
def ValidateAndMeasurePage(self, page, tab, results): del page # unused self._timeline_controller.Stop(tab, results) metric = timeline.ThreadTimesTimelineMetric() renderer_thread = \ self._timeline_controller.model.GetRendererThreadFromTabId(tab.id) if self._report_silk_details: metric.details_to_report = timeline.ReportSilkDetails metric.AddResults(self._timeline_controller.model, renderer_thread, self._timeline_controller.smooth_records, results)
def MeasurePage(self, page, tab, results): metric = timeline.ThreadTimesTimelineMetric() renderer_thread = \ self._timeline_controller.model.GetRendererThreadFromTab(tab) if self.options.report_silk_results: metric.results_to_report = timeline.ReportSilkResults if self.options.report_silk_details: metric.details_to_report = timeline.ReportSilkDetails metric.AddResults(self._timeline_controller.model, renderer_thread, self._timeline_controller.smooth_records, results)
def WillRunActions(self, page, tab): if self.options.metric == 'smoothness': self._metric = smoothness.SmoothnessMetric() elif self.options.metric == 'timeline': self._metric = timeline.ThreadTimesTimelineMetric() self._metric.Start(page, tab) if tab.browser.platform.IsRawDisplayFrameRateSupported(): tab.browser.platform.StartRawDisplayFrameRateMeasurement()
def MeasurePage(self, page, tab, results): metric = timeline.ThreadTimesTimelineMetric( self._timeline_controller.model, self._timeline_controller.renderer_process, self._timeline_controller.action_ranges) if self.options.report_silk_results: metric.results_to_report = timeline.ReportSilkResults if self.options.report_silk_details: metric.details_to_report = timeline.ReportSilkDetails metric.AddResults(tab, results)
def testResults(self): model = model_module.TimelineModel() renderer_main = model.GetOrCreateProcess(1).GetOrCreateThread(2) renderer_main.name = 'CrRendererMain' metric = timeline.ThreadTimesTimelineMetric() metric.details_to_report = timeline.ReportMainThreadOnly results = self.GetResults(metric, model, renderer_main.parent, [_GetInteractionRecord(1,2)]) # Test that all result thread categories exist for name in timeline.TimelineThreadCategories.values(): results.GetPageSpecificValueNamed(timeline.ThreadCpuTimeResultName(name))
def ValidateAndMeasurePage(self, _, tab, results): self._results = results tab.browser.platform.tracing_controller.telemetry_info = ( results.telemetry_info) trace_result = tab.browser.platform.tracing_controller.StopTracing() # TODO(charliea): This is part of a three-sided Chromium/Telemetry patch # where we're changing the return type of StopTracing from a TraceValue to a # (TraceValue, nonfatal_exception_list) tuple. Once the tuple return value # lands in Chromium, the non-tuple logic should be deleted. if isinstance(trace_result, tuple): trace_result = trace_result[0] trace_value = trace.TraceValue( results.current_page, trace_result, file_path=results.telemetry_info.trace_local_path, remote_path=results.telemetry_info.trace_remote_path, upload_bucket=results.telemetry_info.upload_bucket, cloud_url=results.telemetry_info.trace_remote_url) results.AddValue(trace_value) model = model_module.TimelineModel(trace_result) renderer_thread = model.GetFirstRendererThread(tab.id) records = _CollectRecordsFromRendererThreads(model, renderer_thread) smoothness_metric = smoothness.SmoothnessMetric() smoothness_metric.AddResults(model, renderer_thread, records, results) thread_times_metric = timeline.ThreadTimesTimelineMetric() thread_times_metric.AddResults(model, renderer_thread, records, results) # TBMv2 metrics. mre_result = metric_runner.RunMetric( trace_value.filename, metrics=['renderingMetric'], extra_import_options={'trackDetailedModelStats': True}, report_progress=False, canonical_url=results.telemetry_info.trace_url) for f in mre_result.failures: results.Fail(f.stack) results.ImportHistogramDicts(mre_result.pairs.get('histograms', []), import_immediately=False)
def testBasic(self): model = model_module.TimelineModel() renderer_main = model.GetOrCreateProcess(1).GetOrCreateThread(2) renderer_main.name = 'CrRendererMain' # Create two frame swaps (Results times should be divided by two) cc_main = model.GetOrCreateProcess(1).GetOrCreateThread(3) cc_main.name = 'Compositor' cc_main.BeginSlice('cc_cat', timeline.FrameTraceName, 10, 10) cc_main.EndSlice(11, 11) cc_main.BeginSlice('cc_cat', timeline.FrameTraceName, 12, 12) cc_main.EndSlice(13, 13) # [ X ] [ Z ] # [ Y ] renderer_main.BeginSlice('cat1', 'X', 10, 0) renderer_main.BeginSlice('cat2', 'Y', 15, 5) renderer_main.EndSlice(16, 5.5) renderer_main.EndSlice(30, 19.5) renderer_main.BeginSlice('cat1', 'Z', 31, 20) renderer_main.BeginSlice('cat1', 'Z', 33, 21) model.FinalizeImport() # Exclude 'Z' using an action-range. metric = timeline.ThreadTimesTimelineMetric( model, renderer_main.parent, action_ranges=[self.GetActionRange(10, 30)]) metric.details_to_report = timeline.ReportMainThreadOnly results = self.GetResults(metric) # Test a couple specific results. assert_results = { timeline.ThreadCpuTimeResultName('renderer_main'): 9.75, timeline.ThreadDetailResultName('renderer_main', 'cat1'): 9.5, timeline.ThreadDetailResultName('renderer_main', 'cat2'): 0.5, timeline.ThreadDetailResultName('renderer_main', 'idle'): 0 } for name, value in assert_results.iteritems(): results.AssertHasPageSpecificScalarValue(name, 'ms', value)