Example #1
0
    def Finalize(self):
        """Finalize this object to prevent more results from being recorded.

    When progress reporting is enabled, also prints a final summary with the
    number of story runs that suceeded, failed, or were skipped.

    It's fine to call this method multiple times, later calls are just a no-op.
    """
        if self.finalized:
            return

        assert self._current_story_run is None, (
            'Cannot finalize while stories are still running.')
        self._finalized = True
        self._RecordBenchmarkFinish()
        self._progress_reporter.DidFinishAllStories(self)

        # Only serialize the trace if output_format is json or html.
        if (self._output_dir and any(
                isinstance(o, html_output_formatter.HtmlOutputFormatter)
                for o in self._output_formatters)):
            # Just to make sure that html trace is there in artifacts dir
            results_processor.SerializeAndUploadHtmlTraces(self)

        for output_formatter in self._output_formatters:
            output_formatter.Format(self)
            output_formatter.PrintViewResults()
            output_formatter.output_stream.close()
Example #2
0
    def PopulateHistogramSet(self):
        if len(self._histograms):
            return

        # We ensure that html traces are serialized and uploaded if necessary
        results_processor.SerializeAndUploadHtmlTraces(self)

        chart_json = chart_json_output_formatter.ResultsAsChartDict(self)
        chart_json['label'] = self.label
        chart_json['benchmarkStartMs'] = self.benchmark_start_us / 1000.0

        file_descriptor, chart_json_path = tempfile.mkstemp()
        os.close(file_descriptor)
        json.dump(chart_json, file(chart_json_path, 'w'))

        vinn_result = convert_chart_json.ConvertChartJson(chart_json_path)

        os.remove(chart_json_path)

        if vinn_result.returncode != 0:
            logging.error('Error converting chart json to Histograms:\n' +
                          vinn_result.stdout)
            return []
        self._histograms.ImportDicts(json.loads(vinn_result.stdout))
        self._histograms.ImportDicts(self._histogram_dicts_to_add)
Example #3
0
  def PrintSummary(self):
    self._progress_reporter.DidFinishAllStories(self)

    # Only serialize the trace if output_format is json or html.
    if (self._output_dir and
        any(isinstance(o, html_output_formatter.HtmlOutputFormatter)
            for o in self._output_formatters)):
      # Just to make sure that html trace is there in artifacts dir
      results_processor.SerializeAndUploadHtmlTraces(self)

    for output_formatter in self._output_formatters:
      output_formatter.Format(self)
      output_formatter.PrintViewResults()
Example #4
0
    def Finalize(self, exc_value=None):
        """Finalize this object to prevent more results from being recorded.

    When progress reporting is enabled, also prints a final summary with the
    number of story runs that suceeded, failed, or were skipped.

    It's fine to call this method multiple times, later calls are just a no-op.
    """
        if self.finalized:
            return

        if exc_value is not None:
            self.InterruptBenchmark(repr(exc_value))
            self._current_story_run = None
        else:
            assert self._current_story_run is None, (
                'Cannot finalize while stories are still running.')

        self._finalized = True
        self._progress_reporter.DidFinishAllStories(self)

        # Make sure that html traces are recorded as artifacts.
        # TODO(crbug.com/981349): Remove this after trace serialization is
        # implemented in Results Processor.
        results_processor.SerializeAndUploadHtmlTraces(self)

        # TODO(crbug.com/981349): Ideally we want to write results for each story
        # run individually at DidRunPage when the story finished executing. For
        # now, however, we need to wait until this point after html traces have
        # been serialized, uploaded, and recorded as artifacts for them to show up
        # in intermediate results. When both trace serialization and artifact
        # upload are handled by results_processor, remove the for-loop from here
        # and write results instead at the end of each story run.
        for run in self._all_story_runs:
            self._WriteJsonLine(run.AsDict())
        self._RecordBenchmarkFinish()

        for output_formatter in self._output_formatters:
            output_formatter.Format(self)
            output_formatter.PrintViewResults()
            output_formatter.output_stream.close()