Exemplo n.º 1
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))
Exemplo n.º 2
0
def ExtractValuesFromHistograms(test_paths_to_match, histograms_by_path,
                                histogram_name, grouping_label, story,
                                statistic):
    result_values = []
    matching_histograms = list(
        itertools.chain.from_iterable(
            histograms_by_path.get(histogram)
            for histogram in test_paths_to_match
            if histogram in histograms_by_path))
    logging.debug('Histograms in results: %s', histograms_by_path.keys())
    if matching_histograms:
        logging.debug('Found %s matching histograms: %s',
                      len(matching_histograms),
                      [h.name for h in matching_histograms])
        for h in matching_histograms:
            result_values.extend(_GetValuesOrStatistic(statistic, h))
    elif histogram_name:
        # Histograms don't exist, which means this is summary
        summary_value = []
        for test_path, histograms_for_test_path in histograms_by_path.items():
            for test_path_to_match in test_paths_to_match:
                if test_path.startswith(test_path_to_match):
                    for h in histograms_for_test_path:
                        summary_value.extend(
                            _GetValuesOrStatistic(statistic, 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 histogram_name:
        if matching_histograms:
            raise errors.ReadValueNoValues()
        else:
            conditions = {'histogram': histogram_name}
            if grouping_label:
                conditions['grouping_label'] = grouping_label
            if story:
                conditions['story'] = story
            reason = ', '.join(list(':'.join(i) for i in conditions.items()))
            raise errors.ReadValueNotFound(reason)
    return result_values