def __init__(self, overhead_level=NO_OVERHEAD_LEVEL):
        """As the amount of instrumentation increases, so does the overhead.
    The user of the measurement chooses the overhead level that is appropriate,
    and the tracing is filtered accordingly.

    overhead_level: Can either be a custom TracingCategoryFilter object or
        one of NO_OVERHEAD_LEVEL, MINIMAL_OVERHEAD_LEVEL or
        DEBUG_OVERHEAD_LEVEL.
    """
        self._category_filter = None
        if isinstance(overhead_level,
                      tracing_category_filter.TracingCategoryFilter):
            self._category_filter = overhead_level
        elif overhead_level in ALL_OVERHEAD_LEVELS:
            if overhead_level == NO_OVERHEAD_LEVEL:
                self._category_filter = tracing_category_filter.CreateNoOverheadFilter(
                )
            elif overhead_level == MINIMAL_OVERHEAD_LEVEL:
                self._category_filter = (
                    tracing_category_filter.CreateMinimalOverheadFilter())
            else:
                self._category_filter = (
                    tracing_category_filter.CreateDebugOverheadFilter())
        else:
            raise Exception(
                "Overhead level must be a TracingCategoryFilter object"
                " or valid overhead level string."
                " Given overhead level: %s" % overhead_level)

        self._tracing_options = tracing_options.TracingOptions()
        self._tracing_options.enable_chrome_trace = True
        self._tracing_options.enable_platform_display_trace = True
Exemplo n.º 2
0
 def CreateTimelineBasedMeasurementOptions(self):
     cat_filter = tracing_category_filter.CreateNoOverheadFilter()
     # blink.console category is required to make sure that Chrome can output
     # interaction records in its tracing data.
     cat_filter.AddIncludedCategory('blink.console')
     cat_filter.AddIncludedCategory('v8')
     options = timeline_based_measurement.Options(overhead_level=cat_filter)
     options.SetTimelineBasedMetrics([v8_metric.MessageLoopLatencyMetric()])
     return options
Exemplo n.º 3
0
 def WillNavigateToPage(self, page, tab):
   self._timeline_controller = timeline_controller.TimelineController(
       enable_auto_issuing_record=False)
   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.º 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 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())
    with action_runner.CreateInteraction('InteractionName',
                                                 **interaction_kwargs):
      pass
    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))
Exemplo n.º 7
0
 def SetNoOverheadFilter(self):
     self._tracing_category_filter = (
         tracing_category_filter.CreateNoOverheadFilter())