예제 #1
0
  def ValidateAndMeasurePage(self, page, tab, results):
    tab.WaitForJavaScriptExpression('__pc_load_time', 60)

    chart_name_prefix = ('cold_' if self.IsRunCold(page.url) else
                         'warm_')

    results.AddValue(scalar.ScalarValue(
        results.current_page, '%stimes-page_load_time' % chart_name_prefix,
        'ms', tab.EvaluateJavaScript('__pc_load_time'),
        description='Average page load time. Measured from '
                    'performance.timing.navigationStart until the completion '
                    'time of a layout after the window.load event. Cold times '
                    'are the times when the page is loaded cold, i.e. without '
                    'loading it before, and warm times are times when the '
                    'page is loaded after being loaded previously.'))
    results.AddValue(scalar.ScalarValue(
        results.current_page, '%stimes-time_to_onload' % chart_name_prefix,
        'ms', tab.EvaluateJavaScript('performance.timing.loadEventStart'
                                     '- performance.timing.navigationStart'),
        description='Time to onload. This is temporary metric to check that '
                    'PCv1 and PCv2 emit similar results'))

    # TODO(kouhei): Remove below. crbug.com/616342
    results.AddValue(scalar.ScalarValue(
        results.current_page, '%stimes.page_load_time' % chart_name_prefix,
        'ms', tab.EvaluateJavaScript('__pc_load_time'),
        description='Average page load time. Measured from '
                    'performance.timing.navigationStart until the completion '
                    'time of a layout after the window.load event. Cold times '
                    'are the times when the page is loaded cold, i.e. without '
                    'loading it before, and warm times are times when the '
                    'page is loaded after being loaded previously.'))
    results.AddValue(scalar.ScalarValue(
        results.current_page, '%stimes.time_to_onload' % chart_name_prefix,
        'ms', tab.EvaluateJavaScript('performance.timing.loadEventStart'
                                     '- performance.timing.navigationStart'),
        description='Time to onload. This is temporary metric to check that '
                    'PCv1 and PCv2 emit similar results'))

    self._has_loaded_page[page.url] += 1

    self._power_metric.Stop(page, tab)
    self._memory_metric.Stop(page, tab)
    self._memory_metric.AddResults(tab, results)
    self._power_metric.AddResults(tab, results)

    self._cpu_metric.Stop(page, tab)
    self._cpu_metric.AddResults(tab, results)

    if self._report_speed_index:
      def SpeedIndexIsFinished():
        return self._speedindex_metric.IsFinished(tab)
      util.WaitFor(SpeedIndexIsFinished, 60)
      self._speedindex_metric.Stop(page, tab)
      self._speedindex_metric.AddResults(
          tab, results, chart_name=chart_name_prefix + 'speed_index')
    keychain_metric.KeychainMetric().AddResults(tab, results)
예제 #2
0
    def ValidateAndMeasurePage(self, page, tab, results):
        tab.WaitForDocumentReadyStateToBeComplete()
        iterationCount = 10
        # A single iteration on android takes ~75 seconds, the benchmark times out
        # when running for 10 iterations.
        if tab.browser.platform.GetOSName() == 'android':
            iterationCount = 3

        tab.ExecuteJavaScript("""
        // Store all the results in the benchmarkClient
        benchmarkClient._measuredValues = []
        benchmarkClient.didRunSuites = function(measuredValues) {
          benchmarkClient._measuredValues.push(measuredValues);
          benchmarkClient._timeValues.push(measuredValues.total);
        };
        benchmarkClient.iterationCount = {{ count }};
        startTest();
        """,
                              count=iterationCount)
        tab.WaitForJavaScriptCondition(
            'benchmarkClient._finishedTestCount == benchmarkClient.testsCount',
            timeout=600)
        results.AddValue(
            list_of_scalar_values.ListOfScalarValues(
                page,
                'Total',
                'ms',
                tab.EvaluateJavaScript('benchmarkClient._timeValues'),
                important=True))
        results.AddValue(
            list_of_scalar_values.ListOfScalarValues(
                page,
                'RunsPerMinute',
                'score',
                tab.EvaluateJavaScript(
                    '[parseFloat(document.getElementById("result-number").innerText)];'
                ),
                important=True))

        # Extract the timings for each suite
        for suite_name in self.enabled_suites:
            results.AddValue(
                list_of_scalar_values.ListOfScalarValues(
                    page,
                    suite_name,
                    'ms',
                    tab.EvaluateJavaScript("""
              var suite_times = [];
              for(var i = 0; i < benchmarkClient.iterationCount; i++) {
                suite_times.push(
                    benchmarkClient._measuredValues[i].tests[{{ key }}].total);
              };
              suite_times;
              """,
                                           key=suite_name),
                    important=False))
        keychain_metric.KeychainMetric().AddResults(tab, results)
예제 #3
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."""
    browser = tab.browser
    if len(browser.tabs) != len(page.story_set.stories):
      return

    if browser.tabs < 2:
      raise Exception('Should have at least two tabs for tab switching')

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

    if 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 tab_to_switch in browser.tabs:
      tab_to_switch.Activate()
      def _IsDone():
        # pylint: disable=W0640
        cur_histogram = histogram_util.GetHistogram(
            histogram_type, histogram_name, tab_to_switch)
        diff_histogram = histogram_util.SubtractHistogram(
            cur_histogram, prev_histogram)
        # TODO(deanliao): Add SubtractHistogramRawValue to process histogram
        #     object instead of JSON string.
        diff_histogram_count = json.loads(diff_histogram).get('count', 0)
        return diff_histogram_count > 0
      util.WaitFor(_IsDone, 30)

      # We need to get histogram again instead of getting cur_histogram as
      # variables modified inside inner function cannot be retrieved. However,
      # inner function can see external scope's variables.
      prev_histogram = histogram_util.GetHistogram(
          histogram_type, histogram_name, tab_to_switch)

    last_histogram = prev_histogram
    total_diff_histogram = histogram_util.SubtractHistogram(last_histogram,
                                                            first_histogram)
    results.AddSummaryValue(
        histogram.HistogramValue(None, display_name, 'ms',
                                 raw_value_json=total_diff_histogram,
                                 important=False))

    keychain_metric.KeychainMetric().AddResults(tab, results)
예제 #4
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,
                                     'ms',
                                     raw_value_json=diff_histogram,
                                     important=False))

        keychain_metric.KeychainMetric().AddResults(tab, results)
예제 #5
0
  def ValidateAndMeasurePage(self, page, tab, results):
    """record the ending histogram for the tab switching metric."""
    last_histogram = self._GetTabSwitchHistogram(tab)
    total_diff_histogram = histogram_util.SubtractHistogram(last_histogram,
                            self._first_histogram)

    display_name = 'MPArch_RWH_TabSwitchPaintDuration'
    results.AddSummaryValue(
        histogram.HistogramValue(None, display_name, 'ms',
            raw_value_json=total_diff_histogram,
            important=False))

    keychain_metric.KeychainMetric().AddResults(tab, results)
예제 #6
0
    def ValidateAndMeasurePage(self, page, tab, results):
        tab.WaitForDocumentReadyStateToBeComplete()
        iterationCount = 10
        # A single iteration on android takes ~75 seconds, the benchmark times out
        # when running for 10 iterations.
        if tab.browser.platform.GetOSName() == 'android':
            iterationCount = 3

        # TODO(catapult:#3028): Fix interpolation of JavaScript values.
        tab.ExecuteJavaScript("""
        // Store all the results in the benchmarkClient
        benchmarkClient._measuredValues = []
        benchmarkClient.didRunSuites = function(measuredValues) {
          benchmarkClient._measuredValues.push(measuredValues);
          benchmarkClient._timeValues.push(measuredValues.total);
        };
        benchmarkClient.iterationCount = %d;
        startTest();
        """ % iterationCount)
        tab.WaitForJavaScriptExpression(
            'benchmarkClient._finishedTestCount == benchmarkClient.testsCount',
            600)
        results.AddValue(
            list_of_scalar_values.ListOfScalarValues(
                page,
                'Total',
                'ms',
                tab.EvaluateJavaScript('benchmarkClient._timeValues'),
                important=True))

        # Extract the timings for each suite
        for suite_name in self.enabled_suites:
            results.AddValue(
                list_of_scalar_values.ListOfScalarValues(
                    page,
                    suite_name,
                    'ms',
                    # TODO(catapult:#3028): Fix interpolation of JavaScript values.
                    tab.EvaluateJavaScript("""
              var suite_times = [];
              for(var i = 0; i < benchmarkClient.iterationCount; i++) {
                suite_times.push(
                    benchmarkClient._measuredValues[i].tests['%s'].total);
              };
              suite_times;
              """ % suite_name),
                    important=False))
        keychain_metric.KeychainMetric().AddResults(tab, results)
예제 #7
0
  def ValidateAndMeasurePage(self, page, tab, results):
    tab.WaitForJavaScriptExpression('__pc_load_time', 60)

    chart_name_prefix = ('cold_' if self.IsRunCold(page.url) else
                         'warm_')

    results.AddValue(scalar.ScalarValue(
        results.current_page, '%stimes.page_load_time' % chart_name_prefix,
        'ms', tab.EvaluateJavaScript('__pc_load_time'),
        description='Average page load time. Measured from '
                    'performance.timing.navigationStart until the completion '
                    'time of a layout after the window.load event. Cold times '
                    'are the times when the page is loaded cold, i.e. without '
                    'loading it before, and warm times are times when the '
                    'page is loaded after being loaded previously.'))

    self._has_loaded_page[page.url] += 1

    self._power_metric.Stop(page, tab)
    self._memory_metric.Stop(page, tab)
    self._memory_metric.AddResults(tab, results)
    self._power_metric.AddResults(tab, results)

    self._cpu_metric.Stop(page, tab)
    self._cpu_metric.AddResults(tab, results)
    if self._record_v8_object_stats:
      self._v8_object_stats_metric.Stop(page, tab)
      self._v8_object_stats_metric.AddResults(tab, results)

    if self._report_speed_index:
      def SpeedIndexIsFinished():
        return self._speedindex_metric.IsFinished(tab)
      util.WaitFor(SpeedIndexIsFinished, 60)
      self._speedindex_metric.Stop(page, tab)
      self._speedindex_metric.AddResults(
          tab, results, chart_name=chart_name_prefix+'speed_index')
    keychain_metric.KeychainMetric().AddResults(tab, results)
예제 #8
0
 def ValidateAndMeasurePage(self, page, tab, results):
     keychain_metric.KeychainMetric().AddResults(tab, results)
     startup_metric.StartupMetric().AddResults(tab, results)