# class Benchmark::IPS::Stats::SD

### Attributes

error[R]
samples[R]

### Public Class Methods

new(samples, measured_us, iterations) click to toggle source

    # File lib/benchmark/ips/stats/sd.rb, line 9
    def initialize(samples, measured_us, iterations)
      @samples = samples
      @mean = Timing::MICROSECONDS_PER_SECOND * (iterations.to_f / measured_us)
      @error = Timing.stddev(samples, @mean).round
    end

### Public Instance Methods

central_tendency() click to toggle source

Average stat value @return [Float] `central_tendency`

    # File lib/benchmark/ips/stats/sd.rb, line 17
    def central_tendency
      @mean
    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/sd.rb, line 25
    def slowdown(baseline)
      if baseline.central_tendency > central_tendency
        [baseline.central_tendency.to_f / central_tendency, nil]
      else
        [central_tendency.to_f / baseline.central_tendency, nil]
      end
    end

speedup(baseline) click to toggle source

    # File lib/benchmark/ips/stats/sd.rb, line 33
    def speedup(baseline)
      baseline.slowdown(self)
    end