<commit_before>require 'benchmark'

def benchmark(&b)
  runs = 100
  
  Benchmark.bmbm do |x|
    x.report { runs.times { b.call } }
  end
end

def with_utf8_file(filename)
  File.open(filename, 'r:utf-8') do |file|
    yield file.read
  end
end<commit_msg>Output mean as well.<commit_after>require 'benchmark'

def benchmark(&b)
  runs = 100
  
  total = Benchmark.measure { runs.times { b.call } }
  mean = total / runs
  $stderr.puts "mean: #{mean}"
end

def with_utf8_file(filename)
  File.open(filename, 'r:utf-8') do |file|
    yield file.read
  end
end
{'fraction_non_alphanumeric': 0.13059033989266547, 'fraction_numerical': 0.017889087656529516, 'mean_word_length': 3.4444444444444446, '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': '1819659', 'n_tokens_mistral': 224, 'n_tokens_neox': 216, 'n_words': 53}