<commit_before># encoding: utf-8

require 'benchmark'

module Benchmark
  module Perf
    # Calculate arithemtic average of measurements
    #
    # @param [Array[Float]] measurements
    #
    # @return [Float]
    #   the average of given measurements
    #
    # @api public
    def average(measurements)
      return 0 if measurements.empty?
      measurements.reduce(&:+).to_f / measurements.size
    end

    # Calculate standard deviation
    #
    # @param [Array[Float]] measurements
    #
    # @api public
    def std_dev(measurements)
      return 0 if measurements.empty?
      average = average(measurements)
      Math.sqrt(
        measurements.inject(0) do |sum, x|
          sum + (x - average) ** 2
        end.to_f / (measurements.size - 1)
      )
    end

    extend Benchmark::Perf
  end # Perf

  class Performance
    attr_reader :io
<commit_msg>Change to better express intent.<commit_after># encoding: utf-8

require 'benchmark'

module Benchmark
  module Perf
    # Calculate arithemtic average of measurements
    #
    # @param [Array[Float]] measurements
    #
    # @return [Float]
    #   the average of given measurements
    #
    # @api public
    def average(measurements)
      return 0 if measurements.empty?
      measurements.reduce(&:+).to_f / measurements.size
    end

    # Calculate standard deviation
    #
    # @param [Array[Float]] measurements
    #
    # @api public
    def std_dev(measurements)
      return 0 if measurements.empty?
      average = average(measurements)
      Math.sqrt(
        measurements.reduce(0) do |sum, x|
          sum + (x - average)**2
        end.to_f / (measurements.size - 1)
      )
    end

    extend Benchmark::Perf
  end # Perf

  class Performance
    attr_reader :io

{'fraction_non_alphanumeric': 0.09266628766344515, 'fraction_numerical': 0.006822057987492893, 'mean_word_length': 2.371647509578544, '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': '6850011', 'n_tokens_mistral': 543, 'n_tokens_neox': 521, 'n_words': 147}