<commit_before># Licensed under a 3-clause BSD style license - see LICENSE.rst
# -*- coding: utf-8 -*-

from __future__ import absolute_import, division, unicode_literals, print_function

import os
import re
import itertools
import six

from ..console import log
from ..publishing import OutputPublisher
from ..results import compatible_results
from ..step_detect import detect_regressions

from .. import util


class Regressions(OutputPublisher):
    name = "regressions"
    button_label = "Show regressions"
    description = "Display information about recent regressions"

    @classmethod
    def publish(cls, conf, repo, benchmarks, graphs, hash_to_date):
        # Analyze the data in the graphs --- it's been cleaned up and
        # it's easier to work with than the results directly

        regressions = []
        seen = {}
        date_to_hash = dict((d, h) for h, d in six.iteritems(hash_to_date))

        data_filter = _GraphDataFilter(conf, repo, hash_to_date)

        all_params = {}
        for graph in six.itervalues(graphs):
            for key, value in six.iteritems(graph.params):
                all_params.setdefault(key, set())
                if value:
                    all_params[key].add(value)

        for file_name, graph in six.iteritems(graphs):
            if 'summary' in graph.params:
                continue
            log.add('.')

            benchmark_name = os.path.basename(file_name)
            benchmark = benchmarks.get(benchmark_name)
            if not benchmark:
                continue

            graph_data = data_filter.get_graph_data(graph, benchmark)

            for j, entry_name, times, values in graph_data:
                result = cls._analyze_data(times, values)
                if result is None:
                    continue

                # Check if range is a single commit
                commit_a = date_to_hash[result[0]]
                commit_b = date_to_hash[result[1]]
                spec = repo.get_range_spec(commit_a, commit_b)
                commits = repo.get_hashes_from_range(spec)
                if len(commits) == 1:
                    commit_a = None

                # Select unique graph params
                graph_params = {}
                for name, value in six.iteritems(graph.params):
                    if len(all_params[name]) > 1:<commit_msg>Print status information during regression computations<commit_after># Licensed under a 3-clause BSD style license - see LICENSE.rst
# -*- coding: utf-8 -*-

from __future__ import absolute_import, division, unicode_literals, print_function

import os
import re
import itertools
import time
import six

from ..console import log
from ..publishing import OutputPublisher
from ..results import compatible_results
from ..step_detect import detect_regressions

from .. import util


class Regressions(OutputPublisher):
    name = "regressions"
    button_label = "Show regressions"
    description = "Display information about recent regressions"

    @classmethod
    def publish(cls, conf, repo, benchmarks, graphs, hash_to_date):
        # Analyze the data in the graphs --- it's been cleaned up and
        # it's easier to work with than the results directly

        regressions = []
        seen = {}
        date_to_hash = dict((d, h) for h, d in six.iteritems(hash_to_date))

        data_filter = _GraphDataFilter(conf, repo, hash_to_date)

        all_params = {}
        for graph in six.itervalues(graphs):
            for key, value in six.iteritems(graph.params):
                all_params.setdefault(key, set())
                if value:
                    all_params[key].add(value)

        last_percentage_time = time.time()
        num_items = len(graphs)

        for j, item in enumerate(six.iteritems(graphs)):
            file_name, graph = item
            if 'summary' in graph.params:
                continue

            # Print progress information
            log.add('.')
            if time.time() - last_percentage_time > 10:
                log.add('{0:.0f}%'.format(100*j/num_items))
                last_percentage_time = time.time()

            benchmark_name = os.path.basename(file_name)
            benchmark = benchmarks.get(benchmark_name)
            if not benchmark:
                continue

            graph_data = data_filter.get_graph_data(graph, benchmark)

            for j, entry_name, times, values in graph_data:
                result = cls._analyze_data(times, values)
                if result is None:
                    continue

                # Check if range is a single commit
                commit_a = date_to_hash[result[0]]
                commit_b = date_to_hash[result[1]]
                spec = repo.get_range_spec(commit_a, commit_b)
                commits = repo.get_hashes_from_range(spec)
                if len(commits) == 1:
                    commit_a = None

                # Select unique graph params
                graph_params = {}
                for name, value in six.iteritems(graph.params):
                    if len(all_params[name]) > 1:
{'fraction_non_alphanumeric': 0.07991360691144708, 'fraction_numerical': 0.003730610642057726, 'mean_word_length': 2.0070838252656436, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7429740', 'n_tokens_mistral': 1452, 'n_tokens_neox': 1335, 'n_words': 397}