コード例 #1
0
    def testAddResultsWithThreadTime(self):
        # Wall time diagram:
        #           1         2         3         4
        # 01234567890123456789012345678901234567890123456789
        #      [               x.y               ]
        #                                 [  Interaction.LogicalName/is_fast  ]
        renderer_thread_helper = RendererThreadHelper(wall_start=5,
                                                      wall_duration=35,
                                                      thread_start=0,
                                                      thread_duration=54)
        renderer_thread_helper.AddInteraction(wall_start=32,
                                              wall_duration=37,
                                              thread_start=51,
                                              thread_duration=33)

        metric = fast_metric.FastMetric()
        results = renderer_thread_helper.MeasureFakePage(metric)

        expected_values = [
            ('fast-cpu_time', 'ms', 3),  # 54 - 51; thread overlap
            ('fast-duration', 'ms', 37),  # total interaction wall duration
            ('fast-idle_time', 'ms',
             29),  # 37 - ((5 + 35) - 32); interaction wall
            # time outside of renderer wall time.
        ]
        self.assertEqual(expected_values, self.ActualValues(results))
コード例 #2
0
    def testAddResultsWithMultipleInteractions(self):
        # Wall time diagram:
        #           1         2         3         4
        # 01234567890123456789012345678901234567890123456789
        #   [                    x.y                    ]
        #       [ Interaction.Foo/is_fast ]     [ Interaction.Bar/is_fast ]
        renderer_thread_helper = RendererThreadHelper(wall_start=2,
                                                      wall_duration=45,
                                                      thread_start=0,
                                                      thread_duration=101)
        renderer_thread_helper.AddInteraction(logical_name='Foo',
                                              wall_start=6,
                                              wall_duration=27,
                                              thread_start=51,
                                              thread_duration=33)
        renderer_thread_helper.AddInteraction(logical_name='Bar',
                                              wall_start=38,
                                              wall_duration=27,
                                              thread_start=90,
                                              thread_duration=33)

        metric = fast_metric.FastMetric()
        results = renderer_thread_helper.MeasureFakePage(metric)

        expected_values = [
            ('fast-cpu_time', 'ms', 44),  # thread overlap
            ('fast-duration', 'ms',
             54),  # 27 + 27; total interaction wall duration
            ('fast-idle_time', 'ms',
             18),  # 27 - ((2 + 45) - 45); interaction wall
            # time outside of renderer wall time.
        ]
        self.assertEqual(expected_values, self.ActualValues(results))
コード例 #3
0
    def testAddResultsWithoutThreadTime(self):
        # Wall time diagram:
        #           1         2         3         4
        # 01234567890123456789012345678901234567890123456789
        #      [               x.y               ]
        #                                 [  Interaction.LogicalName/is_fast  ]
        renderer_thread_helper = RendererThreadHelper(wall_start=5,
                                                      wall_duration=35,
                                                      thread_start=0,
                                                      thread_duration=54)
        renderer_thread_helper.AddInteraction(
            wall_start=32,
            wall_duration=37)  # no thread_start, no thread_duration

        metric = fast_metric.FastMetric()
        results = renderer_thread_helper.MeasureFakePage(metric)

        expected_values = [
            # cpu_time is skipped because there is no thread time.
            ('fast-duration', 'ms', 37),  # total interaction wall duration
            ('fast-idle_time', 'ms',
             29),  # 37 - ((5 + 35) - 32); interaction wall
            # time outside of renderer wall time.
        ]
        self.assertEqual(expected_values, self.ActualValues(results))
        self.assertIn('Main thread cpu_time cannot be computed for records',
                      self.LogOutput())
コード例 #4
0
  def testAddResultsWithThreadTime(self):
    # Wall time diagram:
    #           1         2         3         4
    # 01234567890123456789012345678901234567890123456789
    #      [               x.y               ]
    #                                 [  Interaction.LogicalName/is_fast  ]
    renderer_thread_helper = RendererThreadHelper(
        wall_start=5, wall_duration=35, thread_start=0, thread_duration=54)
    renderer_thread_helper.AddInteraction(
        wall_start=32, wall_duration=37, thread_start=51, thread_duration=33)

    metric = fast_metric.FastMetric()
    results = renderer_thread_helper.MeasureFakePage(metric)

    expected_values = [
        ('fast-cpu_time', 'ms', 3),  # 54 - 51; thread overlap
        ('fast-duration', 'ms', 37),  # total interaction wall duration
        ('fast-idle_time', 'ms', 29),  # (32 + 37) - (5 + 35); interaction wall
                                       # time outside of renderer wall time.
        ('fast-incremental_marking', 'ms', 0.0),
        ('fast-incremental_marking_outside_idle', 'ms', 0.0),
        ('fast-mark_compactor', 'ms', 0.0),
        ('fast-mark_compactor_outside_idle', 'ms', 0.0),
        ('fast-scavenger', 'ms', 0.0),
        ('fast-scavenger_outside_idle', 'ms', 0.0),
        ('fast-total_garbage_collection', 'ms', 0.0),
        ('fast-total_garbage_collection_outside_idle', 'ms', 0.0)
        ]
    self.assertEqual(expected_values, self.ActualValues(results))
コード例 #5
0
def _GetMetricFromMetricType(metric_type):
  if metric_type == tir_module.IS_FAST:
    return fast_metric.FastMetric()
  if metric_type == tir_module.IS_SMOOTH:
    return smoothness.SmoothnessMetric()
  if metric_type == tir_module.IS_RESPONSIVE:
    return responsiveness_metric.ResponsivenessMetric()
  raise Exception('Unrecognized metric type: %s' % metric_type)
コード例 #6
0
  def testAddResultsWithGarbeCollectionEvents(self):
    # Thread time diagram:
    #           1         2         3         4         5
    # 012345678901234567890123456789012345678901234567890123456789
    #  [                    x.y                                 ]
    #    [            Interaction.Foo/is_fast                      ]
    #    [ Idle ]           [Idle]             [Idle]
    #      [ S ]     [S]     [ I ]      [I]     [MC ]     [MC]
    renderer_thread_helper = RendererThreadHelper(
        wall_start=1, wall_duration=57, thread_start=1, thread_duration=57)
    renderer_thread_helper.AddInteraction(
        logical_name='Foo',
        wall_start=3, wall_duration=58, thread_start=3, thread_duration=58)
    renderer_thread_helper.AddEvent('v8', 'V8.GCIdleNotification', 3, 7, 3, 7)
    renderer_thread_helper.AddEvent('v8', 'V8.GCIdleNotification', 22, 5, 22, 5)
    renderer_thread_helper.AddEvent('v8', 'V8.GCIdleNotification', 41, 5, 41, 5)
    renderer_thread_helper.AddEvent('v8', 'V8.GCScavenger', 5, 4, 5, 4)
    renderer_thread_helper.AddEvent('v8', 'V8.GCScavenger', 15, 2, 15, 2)
    renderer_thread_helper.AddEvent('v8', 'V8.GCIncrementalMarking', 23, 4, 23,
                                    4)
    renderer_thread_helper.AddEvent('v8', 'V8.GCIncrementalMarking', 34, 2, 34,
                                    2)
    renderer_thread_helper.AddEvent('v8', 'V8.GCCompactor', 42, 4, 42, 4)
    renderer_thread_helper.AddEvent('v8', 'V8.GCCompactor', 52, 3, 52, 3)

    metric = fast_metric.FastMetric()
    results = renderer_thread_helper.MeasureFakePage(metric)

    expected_values = [
        ('fast-cpu_time', 'ms', 55),  # thread overlap
        ('fast-duration', 'ms', 58),  # total interaction wall duration
        ('fast-idle_time', 'ms', 3),  # (3 + 58) - (1 + 57); interaction wall
                                       # time outside of renderer wall time.
        ('fast-incremental_marking', 'ms', 6.0),
        ('fast-incremental_marking_outside_idle', 'ms', 2.0),
        ('fast-mark_compactor', 'ms', 7.0),
        ('fast-mark_compactor_outside_idle', 'ms', 3.0),
        ('fast-scavenger', 'ms', 6.0),
        ('fast-scavenger_outside_idle', 'ms', 2.0),
        ('fast-total_garbage_collection', 'ms', 19.0),
        ('fast-total_garbage_collection_outside_idle', 'ms', 7.0)
        ]
    self.assertEqual(expected_values, self.ActualValues(results))