<commit_before>from __future__ import division, print_function, absolute_import

import sys

from .reporter import Reporter


class CsvReporter(Reporter):
    """Prints comma-separated results in microseconds."""

    def __init__(self, csvfile=sys.stdout, dialect='excel', **fmtparam):
        import csv
        self.writer = csv.writer(csvfile, dialect=dialect, **fmtparam)

    def after_benchmark(self, method_name, data, calls, results):
        for n, time in enumerate([time * 1000000 for time in self.times_per_call(calls, results)]):
            self.writer.writerow([method_name, data, n, time])
        sys.stdout.flush()<commit_msg>Better CSV reporter.<commit_after>from __future__ import division, print_function, absolute_import

import sys

from .reporter import Reporter


class CsvReporter(Reporter):
    """Prints comma-separated results in microseconds."""

    def __init__(self, csvfile=sys.stdout, dialect='excel', **fmtparam):
        import csv
        self.writer = csv.writer(csvfile, dialect=dialect, **fmtparam)

    def after_repeat(self, method_name, data, current, total, calls, result):
        self.writer.writerow([method_name, data, current, total, result * 1000000 / calls])
{'fraction_non_alphanumeric': 0.10982658959537572, 'fraction_numerical': 0.011560693641618497, 'mean_word_length': 4.315789473684211, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5369132', 'n_tokens_mistral': 379, 'n_tokens_neox': 342, 'n_words': 98}