<commit_before>var stdout = process.stdout;

module.exports = Reporter;

function Reporter(suite, options){
    if (! (this instanceof Reporter))
        return new Reporter(suite, options);

    return this.initialize(suite, options);
}


Reporter.prototype.initialize = function(suite, options) {
    this.suite = suite;

    var context = suite.ctx;

    var row = serialize.bind(context);

    suite.on('start', function(){
        writeline(indent(suite.name, 2));
    });

    suite.on('test', function(target){
        replaceline(row(target));
    });

    suite.on('cycle', writeline);

    suite.on('complete', function(){
        var results = context.sort().map(row);

        replaceline(results.join('\n'), true);
        writeline();
    });

    return this;
};



function serialize(target, n) {
    if (typeof n == 'number')
        n = (this.length - n) + '.';
    else if (n == void 0)
        n = '•';

    n = fill(n, 3);

    var name = fill(target.name, 16),
        hz   = ((target.hz * 100 | 0) / 100) + ' o/s';

    var text = [n, name, hz].join(' ');

    return indent(fill(text), 4);
}


function fill(str, size) {
    str = str || '';
    size = size || 72;

    var length = str.length;

    while (++length < size)
        str += ' ';

    return str;
}

function indent(str, size) {
    while (size--)
        str = ' ' + str;
    return str;
}


function writeline(line) {
    line = '\n' + (line || '');
    stdout.write(line);
}

function replaceline(line, count) {<commit_msg>simplify reporter<commit_after>var stdout = process.stdout;

module.exports = reporter;

function reporter(suite, options) {
    options = options || {};

    var context = suite.ctx;

    var row = serialize.bind(context);

    suite.on('start', function(){
        writeline(indent(suite.name, 2));
    });

    suite.on('test', function(target){
        replaceline(row(target));
    });

    suite.on('cycle', writeline);

    suite.on('complete', function(){
        var results = context.sort().map(row);

        replaceline(results.join('\n'), true);
        writeline();
    });

    return this;
};



function serialize(target, n) {
    if (typeof n == 'number')
        n = (this.length - n) + '.';
    else if (n == void 0)
        n = '•';

    n = fill(n, 3);

    var name = fill(target.name, 16),
        hz   = ((target.hz * 100 | 0) / 100) + ' o/s';

    var text = [n, name, hz].join(' ');

    return indent(fill(text), 4);
}


function indent(str, size) {
    while (size--)
        str = ' ' + str;
    return str;
}

function fill(str, size) {
    str = str || '';
    size = size || 72;

    var length = str.length;

    while (++length < size)
        str += ' ';

    return str;
}


function writeline(line) {
    line = '\n' + (line || '');
    stdout.write(line);
}

function replaceline(line, count) {
{'fraction_non_alphanumeric': 0.17737969792764313, 'fraction_numerical': 0.01053740779768177, 'mean_word_length': 2.374407582938389, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '755506', 'n_tokens_mistral': 1006, 'n_tokens_neox': 934, 'n_words': 231}