Beispiel #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)
Beispiel #2
0
  def WillNavigateToPage(self, page, tab):
    tab.ExecuteJavaScript("""
        if (window.chrome &&
            chrome.gpuBenchmarking &&
            chrome.gpuBenchmarking.clearImageCache) {
          chrome.gpuBenchmarking.clearImageCache();
        }
    """)
    self._power_metric.Start(page, tab)

    options = tracing_options.TracingOptions()
    options.enable_chrome_trace = True
    # FIXME: Remove the timeline category when impl-side painting is on
    # everywhere.
    category_filter = tracing_category_filter.TracingCategoryFilter(
        'disabled-by-default-devtools.timeline')

    # FIXME: Remove webkit.console when blink.console lands in chromium and
    # the ref builds are updated. crbug.com/386847
    # FIXME: Remove the devtools.timeline category when impl-side painting is
    # on everywhere.
    categories = [
        'blink',
        'devtools.timeline',
        'webkit.console',
        'blink.console'
    ]
    for c in categories:
      category_filter.AddIncludedCategory(c)
    tab.browser.platform.tracing_controller.Start(options, category_filter)
Beispiel #3
0
    def __init__(self,
                 browser_backend,
                 platform_backend,
                 output_path,
                 state,
                 device=None):
        super(AndroidSystraceProfiler,
              self).__init__(browser_backend, platform_backend, output_path,
                             state)
        assert self._browser_backend.supports_tracing
        self._output_path = output_path + '-trace.zip'
        self._systrace_output_path = output_path + '.systrace'

        # Use telemetry's own tracing backend instead the combined mode in
        # adb_profile_chrome because some benchmarks also do tracing of their own
        # and the two methods conflict.
        options = tracing_options.TracingOptions()
        options.enable_chrome_trace = True
        self._browser_backend.StartTracing(options, timeout=10)
        command = [
            'python',
            os.path.join(util.GetChromiumSrcDir(), 'tools',
                         'profile_chrome.py'), '--categories', '',
            '--continuous', '--output', self._systrace_output_path, '--json',
            '--systrace', ','.join(_SYSTRACE_CATEGORIES)
        ]
        if device:
            command.extend(['--device', device])
        self._profiler = subprocess.Popen(command,
                                          stdin=subprocess.PIPE,
                                          stdout=subprocess.PIPE)
 def testGotTrace(self):
     options = tracing_options.TracingOptions()
     options.enable_chrome_trace = True
     self._tracing_controller.Start(
         options, tracing_category_filter.TracingCategoryFilter())
     trace_data = self._tracing_controller.Stop()
     # Test that trace data is parsable
     model.TimelineModel(trace_data)
Beispiel #5
0
    def WillNavigateToPage(self, page, tab):
        category_filter = tracing_category_filter.TracingCategoryFilter()

        for category in self._CATEGORIES:
            category_filter.AddIncludedCategory(category)

        options = tracing_options.TracingOptions()
        options.enable_chrome_trace = True

        tab.browser.platform.tracing_controller.Start(
            options, category_filter, self._TIME_OUT_IN_SECONDS)
Beispiel #6
0
 def WillNavigateToPage(self, page, tab):
     # FIXME: Remove webkit.console when blink.console lands in chromium and the
     # ref builds are updated. crbug.com/386847
     custom_categories = ['webkit.console', 'blink.console', 'gpu']
     category_filter = tracing_category_filter.TracingCategoryFilter()
     for c in custom_categories:
         category_filter.AddIncludedCategory(c)
     options = tracing_options.TracingOptions()
     options.enable_chrome_trace = True
     tab.browser.platform.tracing_controller.Start(options, category_filter,
                                                   60)
Beispiel #7
0
 def StartTracing(self, custom_categories=None, timeout=10):
   """Note: this function is deprecated. Prefer platform.tracing_controller."""
   if not isinstance(custom_categories,
                     tracing_category_filter.TracingCategoryFilter):
     category_filter = tracing_category_filter.TracingCategoryFilter(
         filter_string=custom_categories)
   else:
     category_filter = custom_categories
   options = tracing_options.TracingOptions()
   options.enable_chrome_trace = True
   return self.platform.tracing_controller.Start(
       options, category_filter, timeout)
 def SetUp(self, page, tab):
   # FIXME: Remove webkit.console when blink.console lands in chromium and
   # the ref builds are updated. crbug.com/386847
   custom_categories = ['webkit.console', 'blink.console', 'benchmark']
   custom_categories += page.GetSyntheticDelayCategories()
   category_filter = tracing_category_filter.TracingCategoryFilter()
   for c in custom_categories:
     category_filter.AddIncludedCategory(c)
   options = tracing_options.TracingOptions()
   options.enable_chrome_trace = True
   options.enable_platform_display_trace = True
   tab.browser.platform.tracing_controller.Start(options, category_filter, 60)
 def testIsTracingRunning(self):
     tracing_controller = self._browser.platform.tracing_controller
     if not tracing_controller.IsChromeTracingSupported(self._browser):
         return
     self.assertFalse(tracing_controller.is_tracing_running)
     options = tracing_options.TracingOptions()
     options.enable_chrome_trace = True
     category_filter = tracing_category_filter.TracingCategoryFilter()
     tracing_controller.Start(options, category_filter)
     self.assertTrue(tracing_controller.is_tracing_running)
     tracing_controller.Stop()
     self.assertFalse(tracing_controller.is_tracing_running)
 def testGotTrace(self):
     tracing_controller = self._browser.platform.tracing_controller
     if not tracing_controller.IsChromeTracingSupported(self._browser):
         logging.warning('Browser does not support tracing, skipping test.')
         return
     self._StartServer()
     options = tracing_options.TracingOptions()
     options.enable_chrome_trace = True
     tracing_controller.Start(
         options, tracing_category_filter.TracingCategoryFilter())
     trace_data = tracing_controller.Stop()
     # Test that trace data is parsable
     model.TimelineModel(trace_data)
 def __init__(self, browser_backend, platform_backend, output_path, state,
              categories=None):
   super(TraceProfiler, self).__init__(
       browser_backend, platform_backend, output_path, state)
   assert self._browser_backend.supports_tracing
   # We always want flow events when tracing via telemetry.
   categories_with_flow = 'disabled-by-default-toplevel.flow'
   if categories:
     categories_with_flow = ',%s' % categories
   options = tracing_options.TracingOptions()
   options.enable_chrome_trace = True
   self._browser_backend.StartTracing(
       options, categories_with_flow, timeout=10)
Beispiel #12
0
 def testModifiedConsoleTime(self):
     category_filter = tracing_category_filter.TracingCategoryFilter()
     options = tracing_options.TracingOptions()
     options.enable_chrome_trace = True
     self._tab.browser.platform.tracing_controller.Start(
         options, category_filter)
     self.Navigate('blank.html')
     self.assertEquals(
         self._tab.EvaluateJavaScript('document.location.pathname;'),
         '/blank.html')
     self._tab.EvaluateJavaScript('console.time = function() { };')
     with self.assertRaisesRegexp(Exception,
                                  'Page stomped on console.time'):
         self._tab.browser.platform.tracing_controller.Stop()
Beispiel #13
0
 def testStartAndStopTraceMultipleTimes(self):
     options = tracing_options.TracingOptions()
     options.enable_chrome_trace = True
     self._tracing_controller.Start(
         options, tracing_category_filter.TracingCategoryFilter())
     self.assertFalse(
         self._tracing_controller.Start(
             options, tracing_category_filter.TracingCategoryFilter()))
     trace_data = self._tracing_controller.Stop()
     # Test that trace data is parsable
     model_module.TimelineModel(trace_data)
     self.assertFalse(self._tracing_controller.is_tracing_running)
     # Calling stop again will raise exception
     self.assertRaises(Exception, self._tracing_controller.Stop)
Beispiel #14
0
  def SetUp(self, page, tab):
    """Starts gathering timeline data.

    """
    # Resets these member variables incase this object is reused.
    self._model = None
    self._renderer_process = None
    if not tab.browser.platform.tracing_controller.IsChromeTracingSupported():
      raise Exception('Not supported')
    category_filter = tracing_category_filter.TracingCategoryFilter(
        filter_string=self.trace_categories)
    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)
Beispiel #15
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))
Beispiel #16
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)
Beispiel #17
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)
    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))
Beispiel #19
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)
Beispiel #20
0
 def WillNavigateToPage(self, page, tab):
     options = tracing_options.TracingOptions()
     options.enable_chrome_trace = True
     category_filter = tracing_category_filter.TracingCategoryFilter(
         'disabled-by-default-cc.debug.cdp-perf')
     tab.browser.platform.tracing_controller.Start(options, category_filter)
Beispiel #21
0
options = browser_options.BrowserFinderOptions();
parser = options.CreateParser();
(_, args) = parser.parse_args();

browserFactory = browser_finder.FindBrowser(options);

with browserFactory.Create(options) as browser:
  tab = browser.tabs.New();
  tab.Activate();
  for i in browser.tabs:
    if i == tab.id:
      continue
    browser.tabs.GetTabById(i).Close()

  category_filter = tracing_category_filter.TracingCategoryFilter()
  options = tracing_options.TracingOptions()
  options.enable_chrome_trace = True
  tab.Navigate(args[0]);
  tab.WaitForDocumentReadyStateToBeComplete();
  oldDisplay = tab.EvaluateJavaScript("document.documentElement.style.display");
  browser.platform.tracing_controller.Start(options, category_filter);
  iterations = 1
  if len(args) == 2:
    iterations = int(args[1])
  for i in range(iterations):
    tab.EvaluateJavaScript("(function() { document.documentElement.style.display = 'none'; return document.documentElement.offsetTop; })()");
    tab.EvaluateJavaScript("(function() { document.documentElement.style.display = '" + oldDisplay + "'; console.time('iteration" + str(i) + 
      "'); var x = document.documentElement.offsetTop; console.timeEnd('iteration" + str(i) + "'); })()");
  browser.platform.tracing_controller.Stop().Serialize(sys.stdout);
Beispiel #22
0
 def WillNavigateToPage(self, page, tab):
   cat_string = ','.join(TOPLEVEL_CATEGORIES)
   cat_filter = tracing_category_filter.TracingCategoryFilter(cat_string)
   options = tracing_options.TracingOptions()
   options.enable_chrome_trace = True
   tab.browser.platform.tracing_controller.Start(options, cat_filter, 60)
 def WillRunActions(self, _page, tab):
     options = tracing_options.TracingOptions()
     options.enable_chrome_trace = True
     tab.browser.platform.tracing_controller.Start(
         options, tracing_category_filter.TracingCategoryFilter())