class Benchmark::IPS::Stats::Bootstrap
Attributes
data[R]
error[R]
samples[R]
Public Class Methods
new(samples, confidence)
click to toggle source
# File lib/benchmark/ips/stats/bootstrap.rb, line 9 def initialize(samples, confidence) dependencies @iterations = 10_000 @confidence = (confidence / 100.0).to_s @samples = samples @data = Kalibera::Data.new({[0] => samples}, [1, samples.size]) interval = @data.bootstrap_confidence_interval(@iterations, @confidence) @median = interval.median @error = interval.error end
Public Instance Methods
central_tendency()
click to toggle source
Average stat value @return [Float] central_tendency
# File lib/benchmark/ips/stats/bootstrap.rb, line 22 def central_tendency @median end
dependencies()
click to toggle source
# File lib/benchmark/ips/stats/bootstrap.rb, line 44 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
slowdown(baseline)
click to toggle source
Determines how much slower this stat is than the baseline stat if this average is lower than the faster baseline, higher average is better (e.g. ips) (calculate accordingly) @param baseline [SD|Bootstrap] faster baseline @returns [Array<Float, nil>] the slowdown and the error (not calculated for standard deviation)
# File lib/benchmark/ips/stats/bootstrap.rb, line 30 def slowdown(baseline) low, slowdown, high = baseline.data.bootstrap_quotient(@data, @iterations, @confidence) error = Timing.mean([slowdown - low, high - slowdown]) [slowdown, error] end
speedup(baseline)
click to toggle source
# File lib/benchmark/ips/stats/bootstrap.rb, line 36 def speedup(baseline) baseline.slowdown(self) end