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, args={'step': 'GenerateCompositorFrame'}) cc_main.EndSlice(11, 11) cc_main.BeginSlice('cc_cat', timeline.FrameTraceName, 12, 12, args={'step': 'GenerateCompositorFrame'}) 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), 'tasks', 0.5), (timeline.ThreadTasksResultName(cc_thread), 'tasks', 1.0), (timeline.ThreadCpuTimeResultName(main_thread), 'ms', 9.75), (timeline.ThreadCpuTimeResultName(cc_thread), 'ms', 1.0), (timeline.ThreadDetailResultName(main_thread, 'cat1'), 'ms', 9.5), (timeline.ThreadDetailResultName(main_thread, 'cat2'), 'ms', 0.5), (timeline.ThreadDetailResultName(main_thread, 'idle'), 'ms', 0), ] for name, unit, value in assert_results: results.AssertHasPageSpecificScalarValue(name, unit, value)
def testWithSilkDetails(self): ps = self.CreatePageSetFromFileInUnittestDataDir('scrollable_page.html') measurement = thread_times.ThreadTimes(report_silk_details=True) results = self.RunMeasurement(measurement, ps, options = self._options) self.assertEquals(0, len(results.failures)) main_thread = "renderer_main" expected_trace_categories = ["blink", "cc", "idle"] for trace_category in expected_trace_categories: value_name = timeline.ThreadDetailResultName(main_thread, trace_category) values = results.FindAllPageSpecificValuesNamed(value_name) self.assertEquals(len(values), 1)
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)
def testWithSilkDetails(self): ps = self.CreateStorySetFromFileInUnittestDataDir( 'scrollable_page.html') measurement = thread_times.ThreadTimes(report_silk_details=True) results = self.RunMeasurement(measurement, ps, options=self._options) self.assertFalse(results.had_failures) main_thread = 'renderer_main' expected_trace_categories = ['blink', 'cc', 'idle'] for interval in timeline.IntervalNames: for trace_category in expected_trace_categories: value_name = timeline.ThreadDetailResultName( main_thread, interval, trace_category) values = results.FindAllPageSpecificValuesNamed(value_name) self.assertEquals(len(values), 1)