Пример #1
0
    def _ParseHistograms(self, json_data):
        histograms = histogram_set.HistogramSet()
        try:
            histograms.ImportDicts(json_data)
        except BaseException:
            raise errors.ReadValueUnknownFormat(self._results_filename)

        self._trace_urls = FindTraceUrls(histograms)
        histograms_by_path = CreateHistogramSetByTestPathDict(histograms)
        histograms_by_path_optional_grouping_label = (
            CreateHistogramSetByTestPathDict(histograms,
                                             ignore_grouping_label=True))
        test_paths_to_match = set([
            histogram_helpers.ComputeTestPathFromComponents(
                self._metric,
                grouping_label=self._grouping_label,
                story_name=self._trace_or_story),
            histogram_helpers.ComputeTestPathFromComponents(
                self._metric,
                grouping_label=self._grouping_label,
                story_name=self._trace_or_story,
                needs_escape=False)
        ])
        logging.debug('Test paths to match: %s', test_paths_to_match)

        try:
            result_values = ExtractValuesFromHistograms(
                test_paths_to_match, histograms_by_path, self._metric,
                self._grouping_label, self._trace_or_story, self._statistic)
        except errors.ReadValueNotFound:
            result_values = ExtractValuesFromHistograms(
                test_paths_to_match,
                histograms_by_path_optional_grouping_label, self._metric, None,
                self._trace_or_story, self._statistic)
        return result_values
Пример #2
0
 def HandleHistogramSets(self, task, histogram_dicts):
   histogram_name = task.payload.get('benchmark')
   tir_label = task.payload.get('histogram_options', {}).get('tir_label', '')
   story = task.payload.get('histogram_options', {}).get('story', '')
   statistic = task.payload.get('histogram_options', {}).get('statistic', '')
   histograms = histogram_set.HistogramSet()
   histograms.ImportDicts(histogram_dicts)
   histograms_by_path = read_value_quest.CreateHistogramSetByTestPathDict(
       histograms)
   trace_urls = read_value_quest.FindTraceUrls(histograms)
   test_path_to_match = histogram_helpers.ComputeTestPathFromComponents(
       histogram_name, tir_label=tir_label, story_name=story)
   logging.debug('Test path to match: %s', test_path_to_match)
   result_values = read_value_quest.ExtractValuesFromHistograms(
       test_path_to_match, histograms_by_path, histogram_name, tir_label,
       story, statistic)
   logging.debug('Results: %s', result_values)
   task.payload.update({
       'result_values': result_values,
       'tries': 1,
   })
   if trace_urls:
     task.payload['trace_urls'] = [{
         'key': 'trace',
         'value': url['name'],
         'url': url['url'],
     } for url in trace_urls]
   return [CompleteReadValueAction(self.job, task, 'completed')]
Пример #3
0
 def HandleHistogramSets(self, task, histogram_dicts):
     histogram_name = task.payload.get('benchmark')
     histogram_options = task.payload.get('histogram_options', {})
     grouping_label = histogram_options.get('grouping_label', '')
     story = histogram_options.get('story', '')
     statistic = histogram_options.get('statistic', '')
     histograms = histogram_set.HistogramSet()
     histograms.ImportDicts(histogram_dicts)
     histograms_by_path = read_value_quest.CreateHistogramSetByTestPathDict(
         histograms)
     histograms_by_path_optional_grouping_label = (
         read_value_quest.CreateHistogramSetByTestPathDict(
             histograms, ignore_grouping_label=True))
     trace_urls = read_value_quest.FindTraceUrls(histograms)
     test_paths_to_match = set([
         histogram_helpers.ComputeTestPathFromComponents(
             histogram_name,
             grouping_label=grouping_label,
             story_name=story),
         histogram_helpers.ComputeTestPathFromComponents(
             histogram_name,
             grouping_label=grouping_label,
             story_name=story,
             needs_escape=False)
     ])
     logging.debug('Test paths to match: %s', test_paths_to_match)
     try:
         result_values = read_value_quest.ExtractValuesFromHistograms(
             test_paths_to_match, histograms_by_path, histogram_name,
             grouping_label, story, statistic)
     except errors.ReadValueNotFound:
         result_values = read_value_quest.ExtractValuesFromHistograms(
             test_paths_to_match,
             histograms_by_path_optional_grouping_label, histogram_name,
             None, story, statistic)
     logging.debug('Results: %s', result_values)
     task.payload.update({
         'result_values': result_values,
         'tries': 1,
     })
     if trace_urls:
         task.payload['trace_urls'] = [{
             'key': 'trace',
             'value': url['name'],
             'url': url['url'],
         } for url in trace_urls]
     return [CompleteReadValueAction(self.job, task, 'completed')]
Пример #4
0
    def _Poll(self):
        histogram_dicts = _RetrieveOutputJson(self._isolate_server,
                                              self._isolate_hash,
                                              self._results_filename)
        histograms = histogram_set.HistogramSet()
        histograms.ImportDicts(histogram_dicts)

        histograms_by_path = self._CreateHistogramSetByTestPathDict(histograms)
        self._trace_urls = self._FindTraceUrls(histograms)

        test_path_to_match = histogram_helpers.ComputeTestPathFromComponents(
            self._hist_name, tir_label=self._tir_label, story_name=self._story)
        logging.debug('Test path to match: %s', test_path_to_match)

        # Have to pull out either the raw sample values, or the statistic
        result_values = []
        matching_histograms = []
        if test_path_to_match in histograms_by_path:
            matching_histograms = histograms_by_path.get(
                test_path_to_match, [])

            logging.debug('Found %s matching histograms',
                          len(matching_histograms))

            for h in matching_histograms:
                result_values.extend(self._GetValuesOrStatistic(h))
        elif self._hist_name:
            # Histograms don't exist, which means this is summary
            summary_value = []
            for test_path, histograms_for_test_path in histograms_by_path.items(
            ):
                if test_path.startswith(test_path_to_match):
                    for h in histograms_for_test_path:
                        summary_value.extend(self._GetValuesOrStatistic(h))
                        matching_histograms.append(h)

            logging.debug('Found %s matching summary histograms',
                          len(matching_histograms))
            if summary_value:
                result_values.append(sum(summary_value))

            logging.debug('result values: %s', result_values)

        if not result_values and self._hist_name:
            if matching_histograms:
                raise errors.ReadValueNoValues()
            else:
                conditions = {'histogram': self._hist_name}
                if self._tir_label:
                    conditions['tir_label'] = self._tir_label
                if self._story:
                    conditions['story'] = self._story
                reason = ', '.join(
                    list(':'.join(i) for i in conditions.items()))
                raise errors.ReadValueNotFound(reason)

        self._Complete(result_values=tuple(result_values))
Пример #5
0
    def _Poll(self):
        histogram_dicts = RetrieveOutputJson(self._isolate_server,
                                             self._isolate_hash,
                                             self._results_filename)
        histograms = histogram_set.HistogramSet()
        histograms.ImportDicts(histogram_dicts)

        histograms_by_path = CreateHistogramSetByTestPathDict(histograms)
        histograms_by_path_optional_grouping_label = (
            CreateHistogramSetByTestPathDict(histograms,
                                             ignore_grouping_label=True))
        self._trace_urls = FindTraceUrls(histograms)

        test_paths_to_match = set([
            histogram_helpers.ComputeTestPathFromComponents(
                self._hist_name,
                grouping_label=self._grouping_label,
                story_name=self._trace_or_story),
            histogram_helpers.ComputeTestPathFromComponents(
                self._hist_name,
                grouping_label=self._grouping_label,
                story_name=self._trace_or_story,
                needs_escape=False)
        ])
        logging.debug('Test paths to match: %s', test_paths_to_match)

        # Have to pull out either the raw sample values, or the statistic
        try:
            result_values = ExtractValuesFromHistograms(
                test_paths_to_match, histograms_by_path, self._hist_name,
                self._grouping_label, self._trace_or_story, self._statistic)
        except errors.ReadValueNotFound:
            # In case we didn't find any result_values, we should try finding the
            # histograms without the grouping label applied.
            result_values = ExtractValuesFromHistograms(
                test_paths_to_match,
                histograms_by_path_optional_grouping_label, self._hist_name,
                None, self._trace_or_story, self._statistic)

        self._Complete(result_values=tuple(result_values))
Пример #6
0
    def _Poll(self):
        # TODO(dtu): Remove after data migration.
        if not hasattr(self, '_isolate_server'):
            self._isolate_server = 'https://isolateserver.appspot.com'
        if not hasattr(self, '_results_filename'):
            self._results_filename = 'chartjson-output.json'
        histogram_dicts = _RetrieveOutputJson(self._isolate_server,
                                              self._isolate_hash,
                                              self._results_filename)
        histograms = histogram_set.HistogramSet()
        histograms.ImportDicts(histogram_dicts)
        histograms.ResolveRelatedHistograms()

        histograms_by_path = self._CreateHistogramSetByTestPathDict(histograms)
        self._trace_urls = self._FindTraceUrls(histograms)

        test_path_to_match = histogram_helpers.ComputeTestPathFromComponents(
            self._hist_name, tir_label=self._tir_label, story_name=self._story)

        # Have to pull out either the raw sample values, or the statistic
        result_values = []
        if test_path_to_match in histograms_by_path:
            matching_histograms = histograms_by_path.get(
                test_path_to_match, [])

            for h in matching_histograms:
                result_values.extend(self._GetValuesOrStatistic(h))
        elif self._hist_name:
            # Histograms don't exist, which means this is summary
            summary_value = []
            for test_path, histograms_for_test_path in histograms_by_path.iteritems(
            ):
                if test_path.startswith(test_path_to_match):
                    for h in histograms_for_test_path:
                        summary_value.extend(self._GetValuesOrStatistic(h))
            if summary_value:
                result_values.append(sum(summary_value))

        if not result_values and self._hist_name:
            conditions = {'histogram': self._hist_name}
            if self._tir_label:
                conditions['tir_label'] = self._tir_label
            if self._story:
                conditions['story'] = self._story
            raise ReadValueError('Could not find values matching: %s' %
                                 conditions)

        self._Complete(result_values=tuple(result_values))
Пример #7
0
    def _Poll(self):
        histogram_dicts = _RetrieveOutputJson(self._isolate_server,
                                              self._isolate_hash,
                                              self._results_filename)
        histograms = histogram_set.HistogramSet()
        histograms.ImportDicts(histogram_dicts)

        histograms_by_path = self._CreateHistogramSetByTestPathDict(histograms)
        self._trace_urls = self._FindTraceUrls(histograms)

        test_path_to_match = histogram_helpers.ComputeTestPathFromComponents(
            self._hist_name, tir_label=self._tir_label, story_name=self._story)

        # Have to pull out either the raw sample values, or the statistic
        result_values = []
        matching_histograms = []
        if test_path_to_match in histograms_by_path:
            matching_histograms = histograms_by_path.get(
                test_path_to_match, [])

            for h in matching_histograms:
                result_values.extend(self._GetValuesOrStatistic(h))
        elif self._hist_name:
            # Histograms don't exist, which means this is summary
            summary_value = []
            for test_path, histograms_for_test_path in histograms_by_path.iteritems(
            ):
                if test_path.startswith(test_path_to_match):
                    for h in histograms_for_test_path:
                        summary_value.extend(self._GetValuesOrStatistic(h))
                        matching_histograms.append(h)
            if summary_value:
                result_values.append(sum(summary_value))

        if not result_values and self._hist_name:
            if matching_histograms:
                raise ReadValueError('Found matching histogram data, but no values '\
                    'were generated by the test.')
            else:
                conditions = {'histogram': self._hist_name}
                if self._tir_label:
                    conditions['tir_label'] = self._tir_label
                if self._story:
                    conditions['story'] = self._story
                raise ReadValueError('Could not find values matching: %s' %
                                     conditions)

        self._Complete(result_values=tuple(result_values))
Пример #8
0
    def _Poll(self):
        histogram_dicts = RetrieveOutputJson(self._isolate_server,
                                             self._isolate_hash,
                                             self._results_filename)
        histograms = histogram_set.HistogramSet()
        histograms.ImportDicts(histogram_dicts)

        histograms_by_path = CreateHistogramSetByTestPathDict(histograms)
        self._trace_urls = FindTraceUrls(histograms)

        test_path_to_match = histogram_helpers.ComputeTestPathFromComponents(
            self._hist_name, tir_label=self._tir_label, story_name=self._story)
        logging.debug('Test path to match: %s', test_path_to_match)

        # Have to pull out either the raw sample values, or the statistic
        result_values = ExtractValuesFromHistograms(
            test_path_to_match, histograms_by_path, self._hist_name,
            self._tir_label, self._story, self._statistic)

        self._Complete(result_values=tuple(result_values))