Example #1
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)
Example #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)
Example #3
0
    def testIncludeAndExcludeCategoryRaisesAssertion(self):
        a = tracing_category_filter.TracingCategoryFilter()
        a.AddIncludedCategory('foo')
        self.assertRaises(AssertionError, a.AddExcludedCategory, 'foo')

        a = tracing_category_filter.TracingCategoryFilter()
        a.AddExcludedCategory('foo')
        self.assertRaises(AssertionError, a.AddIncludedCategory, 'foo')

        self.assertRaises(AssertionError,
                          tracing_category_filter.TracingCategoryFilter,
                          'foo,-foo')

        self.assertRaises(AssertionError,
                          tracing_category_filter.TracingCategoryFilter,
                          '-foo,foo')
 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)
Example #5
0
 def StartTracing(self, trace_options, custom_categories=None, timeout=10):
     """ Starts tracing on the first nested call and returns True. Returns False
     and does nothing on subsequent nested calls.
 """
     self._nesting += 1
     if self.is_tracing_running:
         new_category_filter = tracing_category_filter.TracingCategoryFilter(
             filter_string=custom_categories)
         is_subset = new_category_filter.IsSubset(self._category_filter)
         assert (is_subset != False)
         if is_subset == None:
             logging.warning(
                 'Cannot determine if category filter of nested ' +
                 'StartTracing call is subset of current filter.')
         return False
     self._CheckNotificationSupported()
     #TODO(nednguyen): remove this when the stable branch pass 2118.
     if (trace_options.record_mode
             == tracing_options.RECORD_AS_MUCH_AS_POSSIBLE
             and self._chrome_browser_backend.chrome_branch_number
             and self._chrome_browser_backend.chrome_branch_number < 2118):
         logging.warning(
             'Cannot use %s tracing mode on chrome browser with branch version %i,'
             ' (<2118) fallback to use %s tracing mode' %
             (trace_options.record_mode,
              self._chrome_browser_backend.chrome_branch_number,
              tracing_options.RECORD_UNTIL_FULL))
         trace_options.record_mode = tracing_options.RECORD_UNTIL_FULL
     req = {'method': 'Tracing.start'}
     req['params'] = {}
     m = {
         tracing_options.RECORD_UNTIL_FULL:
         'record-until-full',
         tracing_options.RECORD_AS_MUCH_AS_POSSIBLE:
         'record-as-much-as-possible'
     }
     req['params']['options'] = m[trace_options.record_mode]
     self._category_filter = tracing_category_filter.TracingCategoryFilter(
         filter_string=custom_categories)
     if custom_categories:
         req['params']['categories'] = custom_categories
     self._inspector_websocket.SyncRequest(req, timeout)
     self._is_tracing_running = True
     return True
Example #6
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)
Example #7
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)
Example #8
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)
Example #10
0
    def testBasic(self):
        f = tracing_category_filter.TracingCategoryFilter(
            'x,-y,disabled-by-default-z,DELAY(7;foo)')
        self.assertEquals(set(['x']), set(f.included_categories))
        self.assertEquals(set(['y']), set(f.excluded_categories))
        self.assertEquals(set(['disabled-by-default-z']),
                          set(f.disabled_by_default_categories))
        self.assertEquals(set(['DELAY(7;foo)']), set(f.synthetic_delays))

        self.assertTrue('x' in f.filter_string)
        self.assertEquals('x,disabled-by-default-z,-y,DELAY(7;foo)',
                          f.stable_filter_string)
 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)
Example #13
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()
Example #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.supports_tracing:
            raise Exception('Not supported')
        category_filter = tracing_category_filter.TracingCategoryFilter(
            filter_string=self.trace_categories)
        for delay in page.GetSyntheticDelayCategories():
            category_filter.AddSyntheticDelay(delay)
        tab.browser.StartTracing(category_filter)
Example #15
0
 def WillNavigateToPage(self, page, tab):
     tracing_controller = tab.browser.platform.tracing_controller
     # 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',
         'trace_event_overhead'
     ]
     category_filter = tracing_category_filter.TracingCategoryFilter(
         ','.join(custom_categories))
     self._tbm = timeline_based_measurement.TimelineBasedMeasurement(
         timeline_based_measurement.Options(category_filter),
         _CustomResultsWrapper)
     self._tbm.WillRunUserStory(tracing_controller,
                                page.GetSyntheticDelayCategories())
Example #16
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)
Example #17
0
    def testGPUTimesTimelineBasedMeasurementForSmoke(self):
        ps = self.CreateEmptyPageSet()
        ps.AddUserStory(
            TestTimelinebasedMeasurementPage(ps,
                                             ps.base_dir,
                                             trigger_animation=True))

        cat_filter = tracing_category_filter.TracingCategoryFilter(
            'disabled-by-default-gpu.service')
        tbm_option = tbm_module.Options(overhead_level=cat_filter)
        tbm = tbm_module.TimelineBasedMeasurement(tbm_option)
        measurement = tbpt_module.TimelineBasedPageTest(tbm)
        results = self.RunMeasurement(measurement, ps, options=self._options)

        self.assertEquals(0, len(results.failures))
        v = results.FindAllPageSpecificValuesNamed(
            'CenterAnimation-browser_compositor_max_cpu_time')
        self.assertEquals(len(v), 1)
        self.assertGreater(v[0].value, 0)
        v = results.FindAllPageSpecificValuesNamed(
            'DrawerAnimation-browser_compositor_max_cpu_time')
        self.assertEquals(len(v), 1)
        self.assertGreater(v[0].value, 0)
Example #18
0
    def CreateTimelineBasedMeasurementOptions(self):
        cat_string = ','.join(TOPLEVEL_CATEGORIES)
        cat_filter = tracing_category_filter.TracingCategoryFilter(cat_string)

        return timeline_based_measurement.Options(overhead_level=cat_filter)
Example #19
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)
Example #20
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);
Example #21
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)
Example #22
0
    def testIsSubset(self):
        b = tracing_category_filter.TracingCategoryFilter()
        a = tracing_category_filter.TracingCategoryFilter()
        self.assertEquals(a.IsSubset(b), True)

        b = tracing_category_filter.TracingCategoryFilter()
        a = tracing_category_filter.TracingCategoryFilter("test1,test2")
        self.assertEquals(a.IsSubset(b), True)

        b = tracing_category_filter.TracingCategoryFilter()
        a = tracing_category_filter.TracingCategoryFilter("-test1,-test2")
        self.assertEquals(a.IsSubset(b), True)

        b = tracing_category_filter.TracingCategoryFilter("test1,test2")
        a = tracing_category_filter.TracingCategoryFilter()
        self.assertEquals(a.IsSubset(b), None)

        b = tracing_category_filter.TracingCategoryFilter()
        a = tracing_category_filter.TracingCategoryFilter("test*")
        self.assertEquals(a.IsSubset(b), None)

        b = tracing_category_filter.TracingCategoryFilter("test?")
        a = tracing_category_filter.TracingCategoryFilter()
        self.assertEquals(a.IsSubset(b), None)

        b = tracing_category_filter.TracingCategoryFilter("test1")
        a = tracing_category_filter.TracingCategoryFilter("test1,test2")
        self.assertEquals(a.IsSubset(b), False)

        b = tracing_category_filter.TracingCategoryFilter("-test1")
        a = tracing_category_filter.TracingCategoryFilter("test1")
        self.assertEquals(a.IsSubset(b), False)

        b = tracing_category_filter.TracingCategoryFilter("test1,test2")
        a = tracing_category_filter.TracingCategoryFilter("test2,test1")
        self.assertEquals(a.IsSubset(b), True)

        b = tracing_category_filter.TracingCategoryFilter("-test1,-test2")
        a = tracing_category_filter.TracingCategoryFilter("-test2")
        self.assertEquals(a.IsSubset(b), False)

        b = tracing_category_filter.TracingCategoryFilter(
            "disabled-by-default-test1")
        a = tracing_category_filter.TracingCategoryFilter(
            "disabled-by-default-test1,disabled-by-default-test2")
        self.assertEquals(a.IsSubset(b), False)

        b = tracing_category_filter.TracingCategoryFilter(
            "disabled-by-default-test1")
        a = tracing_category_filter.TracingCategoryFilter(
            "disabled-by-default-test2")
        self.assertEquals(a.IsSubset(b), False)
 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())
Example #24
0
 def testAddExcludedCategory(self):
     a = tracing_category_filter.TracingCategoryFilter()
     a.AddExcludedCategory('foo')
     a.AddExcludedCategory('bar')
     a.AddExcludedCategory('foo')
     self.assertEquals(a.stable_filter_string, '-bar,-foo')
Example #25
0
    def testIsSubsetWithSyntheticDelays(self):
        b = tracing_category_filter.TracingCategoryFilter("DELAY(foo;0.016)")
        a = tracing_category_filter.TracingCategoryFilter("DELAY(foo;0.016)")
        self.assertEquals(a.IsSubset(b), True)

        b = tracing_category_filter.TracingCategoryFilter("DELAY(foo;0.016)")
        a = tracing_category_filter.TracingCategoryFilter()
        self.assertEquals(a.IsSubset(b), True)

        b = tracing_category_filter.TracingCategoryFilter()
        a = tracing_category_filter.TracingCategoryFilter("DELAY(foo;0.016)")
        self.assertEquals(a.IsSubset(b), False)

        b = tracing_category_filter.TracingCategoryFilter("DELAY(foo;0.016)")
        a = tracing_category_filter.TracingCategoryFilter("DELAY(foo;0.032)")
        self.assertEquals(a.IsSubset(b), False)

        b = tracing_category_filter.TracingCategoryFilter(
            "DELAY(foo;0.016;static)")
        a = tracing_category_filter.TracingCategoryFilter(
            "DELAY(foo;0.016;oneshot)")
        self.assertEquals(a.IsSubset(b), False)

        b = tracing_category_filter.TracingCategoryFilter(
            "DELAY(foo;0.016),DELAY(bar;0.1)")
        a = tracing_category_filter.TracingCategoryFilter(
            "DELAY(bar;0.1),DELAY(foo;0.016)")
        self.assertEquals(a.IsSubset(b), True)

        b = tracing_category_filter.TracingCategoryFilter(
            "DELAY(foo;0.016),DELAY(bar;0.1)")
        a = tracing_category_filter.TracingCategoryFilter("DELAY(bar;0.1)")
        self.assertEquals(a.IsSubset(b), True)

        b = tracing_category_filter.TracingCategoryFilter(
            "DELAY(foo;0.016),DELAY(bar;0.1)")
        a = tracing_category_filter.TracingCategoryFilter(
            "DELAY(foo;0.032),DELAY(bar;0.1)")
        self.assertEquals(a.IsSubset(b), False)