Exemple #1
0
    def MeasurePage(self, _, tab, results):
        """Although this is called MeasurePage, we're actually using this function
    to cycle through each tab that was opened via DidNavigateToPage and
    thenrecord a single histogram for the tab switching metric.
    """
        histogram_name = 'MPArch.RWH_TabSwitchPaintDuration'
        histogram_type = 'getBrowserHistogram'
        first_histogram = histogram_module.GetHistogramFromDomAutomation(
            histogram_type, histogram_name, tab)
        prev_histogram = first_histogram

        for i in xrange(len(tab.browser.tabs)):
            t = tab.browser.tabs[i]
            t.Activate()

            def _IsDone():
                cur_histogram = histogram_module.GetHistogramFromDomAutomation(
                    histogram_type, histogram_name, tab)
                diff_histogram = histogram_module.SubtractHistogram(
                    cur_histogram, prev_histogram)
                return diff_histogram

            util.WaitFor(_IsDone, 30)
            prev_histogram = histogram_module.GetHistogramFromDomAutomation(
                histogram_type, histogram_name, tab)

        last_histogram = histogram_module.GetHistogramFromDomAutomation(
            histogram_type, histogram_name, tab)
        diff_histogram = histogram_module.SubtractHistogram(
            last_histogram, first_histogram)

        results.AddSummary(histogram_name,
                           '',
                           diff_histogram,
                           data_type='unimportant-histogram')
Exemple #2
0
 def GetValue(self, page, tab, results):
     data = self._GetHistogramFromDomAutomation(tab)
     if not data:
         return
     new_histogram = histogram_module.SubtractHistogram(
         data, self._start_values[page.url + self.name])
     results.Add(self.name,
                 self.units,
                 new_histogram,
                 data_type='unimportant-histogram')
  def testSubtractHistogram(self):
    baseline_histogram = """{"count": 3, "buckets": [
{"low": 1, "high": 2, "count": 1},
{"low": 2, "high": 3, "count": 2}]}"""

    histogram = """{"count": 14, "buckets": [
{"low": 1, "high": 2, "count": 1},
{"low": 2, "high": 3, "count": 3},
{"low": 3, "high": 4, "count": 10}]}"""

    new_histogram = json.loads(
        histogram_module.SubtractHistogram(histogram, baseline_histogram))
    new_buckets = dict()
    for b in new_histogram['buckets']:
      new_buckets[b['low']] = b['count']
    self.assertFalse(1 in new_buckets)
    self.assertEquals(1, new_buckets[2])
    self.assertEquals(10, new_buckets[3])
Exemple #4
0
 def _IsDone():
     cur_histogram = histogram_module.GetHistogramFromDomAutomation(
         histogram_type, histogram_name, tab)
     diff_histogram = histogram_module.SubtractHistogram(
         cur_histogram, prev_histogram)
     return diff_histogram