コード例 #1
0
    def ValidateAndMeasurePage(self, page, tab, results):
        """On the last tab, cycle through each tab that was opened and then record
    a single histogram for the tab switching metric."""
        if len(tab.browser.tabs) != len(page.page_set.pages):
            return

        # Measure power usage of tabs after quiescence.
        util.WaitFor(tab.HasReachedQuiescence, 60)

        if tab.browser.platform.CanMonitorPower():
            self._power_metric.Start(page, tab)
            time.sleep(TabSwitching.SAMPLE_TIME)
            self._power_metric.Stop(page, tab)
            self._power_metric.AddResults(
                tab,
                results,
            )

        histogram_name = 'MPArch.RWH_TabSwitchPaintDuration'
        histogram_type = histogram_util.BROWSER_HISTOGRAM
        display_name = 'MPArch_RWH_TabSwitchPaintDuration'
        first_histogram = histogram_util.GetHistogram(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_util.GetHistogram(
                    histogram_type, histogram_name, tab)
                diff_histogram = histogram_util.SubtractHistogram(
                    cur_histogram, prev_histogram)
                return diff_histogram

            util.WaitFor(_IsDone, 30)
            prev_histogram = histogram_util.GetHistogram(
                histogram_type, histogram_name, tab)

        last_histogram = histogram_util.GetHistogram(histogram_type,
                                                     histogram_name, tab)
        diff_histogram = histogram_util.SubtractHistogram(
            last_histogram, first_histogram)

        results.AddSummaryValue(
            histogram.HistogramValue(None,
                                     display_name,
                                     '',
                                     raw_value_json=diff_histogram,
                                     important=False))
コード例 #2
0
    def MeasurePage(self, page, tab, results):
        """On the last tab, cycle through each tab that was opened and then record
    a single histogram for the tab switching metric."""
        if len(tab.browser.tabs) != len(page.page_set.pages):
            return
        self._cpu_metric.Start(page, tab)
        time.sleep(.5)
        self._cpu_metric.Stop(page, tab)
        # Calculate the idle cpu load before any actions are done.
        self._cpu_metric.AddResults(tab, results, 'idle_cpu_utilization')

        histogram_name = 'MPArch.RWH_TabSwitchPaintDuration'
        histogram_type = histogram_util.BROWSER_HISTOGRAM
        first_histogram = histogram_util.GetHistogram(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_util.GetHistogram(
                    histogram_type, histogram_name, tab)
                diff_histogram = histogram_util.SubtractHistogram(
                    cur_histogram, prev_histogram)
                return diff_histogram

            util.WaitFor(_IsDone, 30)
            prev_histogram = histogram_util.GetHistogram(
                histogram_type, histogram_name, tab)

        last_histogram = histogram_util.GetHistogram(histogram_type,
                                                     histogram_name, tab)
        diff_histogram = histogram_util.SubtractHistogram(
            last_histogram, first_histogram)

        results.AddSummary(histogram_name,
                           '',
                           diff_histogram,
                           data_type='unimportant-histogram')
コード例 #3
0
ファイル: memory.py プロジェクト: amunandar/chromium-1
    def Start(self, page, tab):
        """Start the per-page preparation for this metric.

    Here, this consists of recording the start value of all the histograms.
    """
        for h in _HISTOGRAMS:
            histogram_data = histogram_util.GetHistogram(
                h['type'], h['name'], tab)
            # Histogram data may not be available
            if not histogram_data:
                continue
            self._histogram_start[h['name']] = histogram_data
コード例 #4
0
  def Stop(self, page, tab):
    """Prepare the results for this page.

    The results are the differences between the current histogram values
    and the values when Start() was called.
    """
    assert self._histogram_start, 'Must call Start() first'
    for h in _HISTOGRAMS:
      # Histogram data may not be available
      if h['name'] not in self._histogram_start:
        continue
      histogram_data = histogram_util.GetHistogram(
          h['type'], h['name'], tab)
      self._histogram_delta[h['name']] = histogram_util.SubtractHistogram(
          histogram_data, self._histogram_start[h['name']])
コード例 #5
0
 def _IsDone():
     cur_histogram = histogram_util.GetHistogram(
         histogram_type, histogram_name, tab)
     diff_histogram = histogram_util.SubtractHistogram(
         cur_histogram, prev_histogram)
     return diff_histogram