Sha256: 8d59ac66d0c6aa64decc1f090e7fae8936cbf601bbc5acbb468de5cddd05f7df

Contents?: true

Size: 1.35 KB

Versions: 3

Compression:

Stored size: 1.35 KB

Contents

module Benchmark
  module IPS
    module Stats

      class Bootstrap

        attr_reader :data

        def initialize(samples, confidence)
          dependencies
          @iterations = 10_000
          @confidence = (confidence / 100.0).to_s
          @data = Kalibera::Data.new({[0] => samples}, [1, samples.size])
          interval = @data.bootstrap_confidence_interval(@iterations, @confidence)
          @median = interval.median
          @error = interval.error
        end

        def central_tendency
          @median
        end

        def error
          @error
        end

        def slowdown(baseline)
          low, slowdown, high = baseline.data.bootstrap_quotient(@data, @iterations, @confidence)
          error = Timing.mean([slowdown - low, high - slowdown])
          [slowdown, error]
        end

        def footer
          "with #{(@confidence.to_f * 100).round(1)}% confidence"
        end

        def dependencies
          require 'kalibera'
        rescue LoadError
          puts
          puts "Can't load the kalibera gem - this is required to use the :bootstrap stats options."
          puts "It's optional, so we don't formally depend on it and it isn't installed along with benchmark-ips."
          puts "You probably want to do something like 'gem install kalibera' to fix this."
          abort
        end

      end

    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
motion-benchmark-ips-1.1 lib/project/ips/stats/bootstrap.rb
benchmark-ips-2.7.2 lib/benchmark/ips/stats/bootstrap.rb
benchmark-ips-2.7.1 lib/benchmark/ips/stats/bootstrap.rb