Exemplo n.º 1
0
    def WillNavigateToPage(self, page, tab):
        if not tab.browser.platform.tracing_controller.IsChromeTracingSupported(
                tab.browser):
            raise Exception('Not supported')

        assert self._overhead_level in ALL_OVERHEAD_LEVELS
        if self._overhead_level == NO_OVERHEAD_LEVEL:
            category_filter = tracing_category_filter.CreateNoOverheadFilter()
        # TODO(ernstm): Remove this overhead level when benchmark relevant v8 events
        # become available in the 'benchmark' category.
        elif self._overhead_level == V8_OVERHEAD_LEVEL:
            category_filter = tracing_category_filter.CreateNoOverheadFilter()
            category_filter.AddIncludedCategory('v8')
        elif self._overhead_level == MINIMAL_OVERHEAD_LEVEL:
            category_filter = tracing_category_filter.CreateMinimalOverheadFilter(
            )
        else:
            category_filter = tracing_category_filter.CreateDebugOverheadFilter(
            )

        for delay in page.GetSyntheticDelayCategories():
            category_filter.AddSyntheticDelay(delay)
        options = tracing_options.TracingOptions()
        options.enable_chrome_trace = True
        tab.browser.platform.tracing_controller.Start(options, category_filter)
Exemplo n.º 2
0
 def WillNavigateToPage(self, page, tab):
     self._timeline_controller = timeline_controller.TimelineController()
     if self._report_silk_details:
         # We need the other traces in order to have any details to report.
         self._timeline_controller.trace_categories = None
     else:
         self._timeline_controller.trace_categories = \
             tracing_category_filter.CreateNoOverheadFilter().filter_string
     self._timeline_controller.SetUp(page, tab)
Exemplo n.º 3
0
  def WillRunUserStory(self, tracing_controller,
                       synthetic_delay_categories=None):
    """Configure and start tracing.

    Args:
      app: an app.App subclass instance.
      synthetic_delay_categories: iterable of delays. For example:
          ['DELAY(cc.BeginMainFrame;0.014;alternating)']
          where 'cc.BeginMainFrame' is a timeline event, 0.014 is the delay,
          and 'alternating' is the mode.
    """
    if not tracing_controller.IsChromeTracingSupported():
      raise Exception('Not supported')
    assert self._overhead_level in ALL_OVERHEAD_LEVELS
    if self._overhead_level == NO_OVERHEAD_LEVEL:
      category_filter = tracing_category_filter.CreateNoOverheadFilter()
    # TODO(ernstm): Remove this overhead level when benchmark relevant v8 events
    # become available in the 'benchmark' category.
    elif self._overhead_level == V8_OVERHEAD_LEVEL:
      category_filter = tracing_category_filter.CreateNoOverheadFilter()
      category_filter.AddIncludedCategory('v8')
    elif self._overhead_level == MINIMAL_OVERHEAD_LEVEL:
      category_filter = tracing_category_filter.CreateMinimalOverheadFilter()
    else:
      category_filter = tracing_category_filter.CreateDebugOverheadFilter()

    for new_category_filter in self._category_filters:
      category_filter.AddIncludedCategory(new_category_filter)

    # TODO(slamm): Move synthetic_delay_categories to the TBM options.
    for delay in synthetic_delay_categories or []:
      category_filter.AddSyntheticDelay(delay)
    options = tracing_options.TracingOptions()
    options.enable_chrome_trace = True
    options.enable_platform_display_trace = True
    tracing_controller.Start(options, category_filter)
Exemplo n.º 4
0
    def testGetRendererThreadFromTabId(self):
        self.assertEquals(self._tab.url, 'about:blank')
        # Create 3 tabs. The third tab is closed before we call
        # tracing_controller.Start.
        first_tab = self._tab
        second_tab = self._browser.tabs.New()
        second_tab.Navigate('about:blank')
        second_tab.WaitForDocumentReadyStateToBeInteractiveOrBetter()
        third_tab = self._browser.tabs.New()
        third_tab.Navigate('about:blank')
        third_tab.WaitForDocumentReadyStateToBeInteractiveOrBetter()
        third_tab.Close()
        options = tracing_options.TracingOptions()
        options.enable_chrome_trace = True
        self._browser.platform.tracing_controller.Start(
            options, tracing_category_filter.CreateNoOverheadFilter())
        first_tab.ExecuteJavaScript('console.time("first-tab-marker");')
        first_tab.ExecuteJavaScript('console.timeEnd("first-tab-marker");')
        second_tab.ExecuteJavaScript('console.time("second-tab-marker");')
        second_tab.ExecuteJavaScript('console.timeEnd("second-tab-marker");')
        trace_data = self._browser.platform.tracing_controller.Stop()
        timeline_model = model.TimelineModel(trace_data)

        # Assert that the renderer_thread of the first tab contains
        # 'first-tab-marker'.
        renderer_thread = timeline_model.GetRendererThreadFromTabId(
            first_tab.id)
        first_tab_markers = [
            renderer_thread.IterAllSlicesOfName('first-tab-marker')
        ]
        self.assertEquals(1, len(first_tab_markers))

        # Close second tab and assert that the renderer_thread of the second tab
        # contains 'second-tab-marker'.
        second_tab.Close()
        renderer_thread = timeline_model.GetRendererThreadFromTabId(
            second_tab.id)
        second_tab_markers = [
            renderer_thread.IterAllSlicesOfName('second-tab-marker')
        ]
        self.assertEquals(1, len(second_tab_markers))

        # Third tab wasn't available when we start tracing, so there is no
        # renderer_thread corresponding to it in the the trace.
        self.assertIs(None,
                      timeline_model.GetRendererThreadFromTabId(third_tab.id))
Exemplo n.º 5
0
 def testHighlight(self):
     self.assertEquals(self._tab.url, 'about:blank')
     options = tracing_options.TracingOptions()
     options.enable_chrome_trace = True
     self._browser.platform.tracing_controller.Start(
         options, tracing_category_filter.CreateNoOverheadFilter())
     self._tab.Highlight(rgba_color.WEB_PAGE_TEST_ORANGE)
     self._tab.ClearHighlight(rgba_color.WEB_PAGE_TEST_ORANGE)
     trace_data = self._browser.platform.tracing_controller.Stop()
     timeline_model = model.TimelineModel(trace_data)
     renderer_thread = timeline_model.GetRendererThreadFromTabId(
         self._tab.id)
     found_video_start_event = False
     for event in renderer_thread.async_slices:
         if event.name == '__ClearHighlight.video_capture_start':
             found_video_start_event = True
             break
     self.assertTrue(found_video_start_event)
Exemplo n.º 6
0
    def WillRunUserStory(self,
                         tracing_controller,
                         synthetic_delay_categories=None):
        """Configure and start tracing.

    Args:
      app: an app.App subclass instance.
      synthetic_delay_categories: iterable of delays. For example:
          ['DELAY(cc.BeginMainFrame;0.014;alternating)']
          where 'cc.BeginMainFrame' is a timeline event, 0.014 is the delay,
          and 'alternating' is the mode.
    """
        if not tracing_controller.IsChromeTracingSupported():
            raise Exception('Not supported')

        if isinstance(self._tbm_options.overhead_level,
                      tracing_category_filter.TracingCategoryFilter):
            category_filter = self._tbm_options.overhead_level
        else:
            assert self._tbm_options.overhead_level in ALL_OVERHEAD_LEVELS, (
                "Invalid TBM Overhead Level: %s" %
                self._tbm_options.overhead_level)

            if self._tbm_options.overhead_level == NO_OVERHEAD_LEVEL:
                category_filter = tracing_category_filter.CreateNoOverheadFilter(
                )
            elif self._tbm_options.overhead_level == MINIMAL_OVERHEAD_LEVEL:
                category_filter = tracing_category_filter.CreateMinimalOverheadFilter(
                )
            else:
                category_filter = tracing_category_filter.CreateDebugOverheadFilter(
                )

        for new_category_filter in self._tbm_options.extra_category_filters:
            category_filter.AddIncludedCategory(new_category_filter)

        # TODO(slamm): Move synthetic_delay_categories to the TBM options.
        for delay in synthetic_delay_categories or []:
            category_filter.AddSyntheticDelay(delay)
        options = tracing_options.TracingOptions()
        options.enable_chrome_trace = True
        options.enable_platform_display_trace = True
        tracing_controller.Start(options, category_filter)
Exemplo n.º 7
0
    def VerifyIssuingInteractionRecords(self, **interaction_kwargs):
        action_runner = action_runner_module.ActionRunner(self._tab,
                                                          skip_waits=True)
        self.Navigate('interaction_enabled_page.html')
        action_runner.Wait(1)
        options = tracing_options.TracingOptions()
        options.enable_chrome_trace = True
        self._browser.platform.tracing_controller.Start(
            options, tracing_category_filter.CreateNoOverheadFilter())
        interaction = action_runner.BeginInteraction('InteractionName',
                                                     **interaction_kwargs)
        interaction.End()
        trace_data = self._browser.platform.tracing_controller.Stop()

        records = self.GetInteractionRecords(trace_data)
        self.assertEqual(
            1, len(records),
            'Failed to issue the interaction record on the tracing timeline.'
            ' Trace data:\n%s' % repr(trace_data._raw_data))
        self.assertEqual('InteractionName', records[0].label)
        for attribute_name in interaction_kwargs:
            self.assertTrue(getattr(records[0], attribute_name))