示例#1
0
    def testExpectedResults(self):
        """Test a simply trace will output all expected results."""
        model = model_module.TimelineModel()
        test_thread = model.GetOrCreateProcess(1).GetOrCreateThread(2)
        for slice_item in _CreateGPUSlices(test_thread, 'test_item', 100, 10):
            _AddSliceToThread(test_thread, slice_item)
        model.FinalizeImport()

        metric = gpu_timeline.GPUTimelineMetric()
        results = self.GetResults(metric,
                                  model=model,
                                  renderer_thread=test_thread,
                                  interaction_records=INTERACTION_RECORDS)

        for name, src_type in (('swap', None), ('total', 'cpu'), ('total',
                                                                  'gpu')):
            results.AssertHasPageSpecificScalarValue(
                gpu_timeline.TimelineName(name, src_type, 'max'), 'ms', 10)
            results.AssertHasPageSpecificScalarValue(
                gpu_timeline.TimelineName(name, src_type, 'mean'), 'ms', 10)
            results.AssertHasPageSpecificScalarValue(
                gpu_timeline.TimelineName(name, src_type, 'stddev'), 'ms', 0)

        for tracked_name in gpu_timeline.TRACKED_GL_CONTEXT_NAME.values():
            for source_type in ('cpu', 'gpu'):
                results.AssertHasPageSpecificScalarValue(
                    gpu_timeline.TimelineName(tracked_name, source_type,
                                              'max'), 'ms', 0)
                results.AssertHasPageSpecificScalarValue(
                    gpu_timeline.TimelineName(tracked_name, source_type,
                                              'mean'), 'ms', 0)
                results.AssertHasPageSpecificScalarValue(
                    gpu_timeline.TimelineName(tracked_name, source_type,
                                              'stddev'), 'ms', 0)
示例#2
0
    def testTrackedNameWithContextIDTraces(self):
        """Be sure tracked names with context IDs are recorded correctly."""
        self.assertGreater(len(gpu_timeline.TRACKED_GL_CONTEXT_NAME), 0)

        marker, result = gpu_timeline.TRACKED_GL_CONTEXT_NAME.iteritems().next(
        )
        context_id = '-0x1234'

        model = model_module.TimelineModel()
        test_thread = model.GetOrCreateProcess(1).GetOrCreateThread(2)
        for slice_item in _CreateGPUSlices(test_thread, marker + context_id,
                                           100, 10):
            _AddSliceToThread(test_thread, slice_item)
        model.FinalizeImport()

        metric = gpu_timeline.GPUTimelineMetric()
        results = self.GetResults(metric,
                                  model=model,
                                  renderer_thread=test_thread,
                                  interaction_records=INTERACTION_RECORDS)

        for source_type in ('cpu', 'gpu'):
            results.AssertHasPageSpecificScalarValue(
                gpu_timeline.TimelineName(result, source_type, 'max'), 'ms',
                10)
            results.AssertHasPageSpecificScalarValue(
                gpu_timeline.TimelineName(result, source_type, 'mean'), 'ms',
                10)
            results.AssertHasPageSpecificScalarValue(
                gpu_timeline.TimelineName(result, source_type, 'stddev'), 'ms',
                0)
示例#3
0
    def testFrameSeparationBeforeMarker(self):
        """Test frames are correctly calculated using the frame end marker."""
        model = model_module.TimelineModel()
        test_thread = model.GetOrCreateProcess(1).GetOrCreateThread(2)

        # Mark frame end.
        for slice_item in _CreateFrameEndSlices(test_thread, 105, 5):
            _AddSliceToThread(test_thread, slice_item)

        # First frame is 10 seconds.
        for slice_item in _CreateGPUSlices(test_thread, 'test_item', 100, 10):
            _AddSliceToThread(test_thread, slice_item)

        # Second frame is 20 seconds.
        for slice_item in _CreateGPUSlices(test_thread, 'test_item', 110, 20):
            _AddSliceToThread(test_thread, slice_item)

        model.FinalizeImport()

        metric = gpu_timeline.GPUTimelineMetric()
        results = self.GetResults(metric,
                                  model=model,
                                  renderer_thread=test_thread,
                                  interaction_records=INTERACTION_RECORDS)

        for name, src_type in (('swap', None), ('total', 'cpu'), ('total',
                                                                  'gpu')):
            results.AssertHasPageSpecificScalarValue(
                gpu_timeline.TimelineName(name, src_type, 'max'), 'ms', 20)
            results.AssertHasPageSpecificScalarValue(
                gpu_timeline.TimelineName(name, src_type, 'mean'), 'ms', 15)
            results.AssertHasPageSpecificScalarValue(
                gpu_timeline.TimelineName(name, src_type, 'stddev'), 'ms', 5)
示例#4
0
  def CreateTimelineBasedMeasurementOptions(self):
    cat_string = ','.join(TOPLEVEL_CATEGORIES)
    cat_filter = tracing_category_filter.TracingCategoryFilter(cat_string)

    options = timeline_based_measurement.Options(overhead_level=cat_filter)
    options.SetTimelineBasedMetrics([gpu_timeline.GPUTimelineMetric()])
    return options
示例#5
0
def _GetAllTimelineBasedMetrics():
    # TODO(nednguyen): use discovery pattern to return all the instances of
    # all TimelineBasedMetrics class in web_perf/metrics/ folder.
    # This cannot be done until crbug.com/460208 is fixed.
    return (smoothness.SmoothnessMetric(),
            responsiveness_metric.ResponsivenessMetric(),
            layout.LayoutMetric(), gpu_timeline.GPUTimelineMetric())
示例#6
0
def _GetAllLegacyTimelineBasedMetrics():
    # TODO(nednguyen): use discovery pattern to return all the instances of
    # all TimelineBasedMetrics class in web_perf/metrics/ folder.
    # This cannot be done until crbug.com/460208 is fixed.
    return (smoothness.SmoothnessMetric(), layout.LayoutMetric(),
            gpu_timeline.GPUTimelineMetric(),
            blob_timeline.BlobTimelineMetric(),
            indexeddb_timeline.IndexedDBTimelineMetric(),
            webrtc_rendering_timeline.WebRtcRenderingTimelineMetric())
示例#7
0
    def testOutOfOrderDeviceTraces(self):
        """Out of order device traces are still matched up to correct services."""
        self.assertGreaterEqual(len(gpu_timeline.TRACKED_GL_CONTEXT_NAME), 2)

        tracked_names_iter = gpu_timeline.TRACKED_GL_CONTEXT_NAME.iteritems()
        marker1_name, result1_name = tracked_names_iter.next()
        result2_name = result1_name
        while result2_name == result1_name:
            marker2_name, result2_name = tracked_names_iter.next()

        model = model_module.TimelineModel()
        test_thread = model.GetOrCreateProcess(1).GetOrCreateThread(2)

        # marker1 lasts for 10 seconds.
        service_item1, device_item1 = _CreateGPUSlices(test_thread,
                                                       marker1_name, 100, 10)
        # marker2 lasts for 20 seconds.
        service_item2, device_item2 = _CreateGPUSlices(test_thread,
                                                       marker2_name, 200, 20)

        # Append out of order
        _AddSliceToThread(test_thread, service_item1)
        _AddSliceToThread(test_thread, service_item2)
        _AddSliceToThread(test_thread, device_item2)
        _AddSliceToThread(test_thread, device_item1)

        model.FinalizeImport()

        metric = gpu_timeline.GPUTimelineMetric()
        results = self.GetResults(metric,
                                  model=model,
                                  renderer_thread=test_thread,
                                  interaction_records=INTERACTION_RECORDS)

        for source_type in ('cpu', 'gpu'):
            results.AssertHasPageSpecificScalarValue(
                gpu_timeline.TimelineName(result1_name, source_type, 'max'),
                'ms', 10)
            results.AssertHasPageSpecificScalarValue(
                gpu_timeline.TimelineName(result1_name, source_type, 'mean'),
                'ms', 10)
            results.AssertHasPageSpecificScalarValue(
                gpu_timeline.TimelineName(result1_name, source_type, 'stddev'),
                'ms', 0)
            results.AssertHasPageSpecificScalarValue(
                gpu_timeline.TimelineName(result2_name, source_type, 'max'),
                'ms', 20)
            results.AssertHasPageSpecificScalarValue(
                gpu_timeline.TimelineName(result2_name, source_type, 'mean'),
                'ms', 20)
            results.AssertHasPageSpecificScalarValue(
                gpu_timeline.TimelineName(result2_name, source_type, 'stddev'),
                'ms', 0)
示例#8
0
    def testNoDeviceTraceResults(self):
        """Test expected results when missing device traces."""
        model = model_module.TimelineModel()
        test_thread = model.GetOrCreateProcess(1).GetOrCreateThread(2)
        service_slice, _ = _CreateGPUSlices(test_thread, 'test_item', 100, 10)
        _AddSliceToThread(test_thread, service_slice)
        model.FinalizeImport()

        metric = gpu_timeline.GPUTimelineMetric()
        results = self.GetResults(metric,
                                  model=model,
                                  renderer_thread=test_thread,
                                  interaction_records=INTERACTION_RECORDS)

        for name, source_type in (('swap', None), ('total', 'cpu')):
            results.AssertHasPageSpecificScalarValue(
                gpu_timeline.TimelineName(name, source_type, 'max'), 'ms', 10)
            results.AssertHasPageSpecificScalarValue(
                gpu_timeline.TimelineName(name, source_type, 'mean'), 'ms', 10)
            results.AssertHasPageSpecificScalarValue(
                gpu_timeline.TimelineName(name, source_type, 'stddev'), 'ms',
                0)

        self.assertRaises(AssertionError, results.GetPageSpecificValueNamed,
                          gpu_timeline.TimelineName('total', 'gpu', 'max'))
        self.assertRaises(AssertionError, results.GetPageSpecificValueNamed,
                          gpu_timeline.TimelineName('total', 'gpu', 'mean'))
        self.assertRaises(AssertionError, results.GetPageSpecificValueNamed,
                          gpu_timeline.TimelineName('total', 'gpu', 'stddev'))

        for name in gpu_timeline.TRACKED_GL_CONTEXT_NAME.values():
            results.AssertHasPageSpecificScalarValue(
                gpu_timeline.TimelineName(name, 'cpu', 'max'), 'ms', 0)
            results.AssertHasPageSpecificScalarValue(
                gpu_timeline.TimelineName(name, 'cpu', 'mean'), 'ms', 0)
            results.AssertHasPageSpecificScalarValue(
                gpu_timeline.TimelineName(name, 'cpu', 'stddev'), 'ms', 0)

            self.assertRaises(AssertionError,
                              results.GetPageSpecificValueNamed,
                              gpu_timeline.TimelineName(name, 'gpu', 'max'))
            self.assertRaises(AssertionError,
                              results.GetPageSpecificValueNamed,
                              gpu_timeline.TimelineName(name, 'gpu', 'mean'))
            self.assertRaises(AssertionError,
                              results.GetPageSpecificValueNamed,
                              gpu_timeline.TimelineName(name, 'gpu', 'stddev'))
  def testGPUTimesTimelineBasedMeasurementForSmoke(self):
    ps = self.CreateEmptyPageSet()
    ps.AddStory(TestTimelinebasedMeasurementPage(
        ps, ps.base_dir, trigger_animation=True))

    cat_filter = chrome_trace_category_filter.ChromeTraceCategoryFilter(
        'disabled-by-default-gpu.service')
    tbm_option = tbm_module.Options(overhead_level=cat_filter)
    tbm_option.SetLegacyTimelineBasedMetrics([gpu_timeline.GPUTimelineMetric()])
    tbm = tbm_module.TimelineBasedMeasurement(tbm_option)
    results = self.RunMeasurement(tbm, ps, options=self._options)

    self.assertEquals(0, len(results.failures))
    v = results.FindAllPageSpecificValuesFromIRNamed(
        'CenterAnimation', 'browser_compositor_max_cpu_time')
    self.assertEquals(len(v), 1)
    self.assertGreater(v[0].value, 0)
    v = results.FindAllPageSpecificValuesFromIRNamed(
        'DrawerAnimation', 'browser_compositor_max_cpu_time')
    self.assertEquals(len(v), 1)
    self.assertGreater(v[0].value, 0)