Class: Benchmark::IPS::Stats::SD

Inherits:
Object
  • Object
show all
Includes:
StatsMetric
Defined in:
lib/benchmark/ips/stats/sd.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from StatsMetric

#error_percentage, #overlaps?

Constructor Details

#initialize(samples) ⇒ SD

Returns a new instance of SD.



9
10
11
12
13
# File 'lib/benchmark/ips/stats/sd.rb', line 9

def initialize(samples)
  @samples = samples
  @mean = Timing.mean(samples)
  @error = Timing.stddev(samples, @mean).round
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



7
8
9
# File 'lib/benchmark/ips/stats/sd.rb', line 7

def error
  @error
end

#samplesObject (readonly)

Returns the value of attribute samples.



7
8
9
# File 'lib/benchmark/ips/stats/sd.rb', line 7

def samples
  @samples
end

Instance Method Details

#central_tendencyFloat

Average stat value

Returns:

  • (Float)

    central_tendency



17
18
19
# File 'lib/benchmark/ips/stats/sd.rb', line 17

def central_tendency
  @mean
end


37
38
39
# File 'lib/benchmark/ips/stats/sd.rb', line 37

def footer
  nil
end

#slowdown(baseline) ⇒ Object

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)

Parameters:



25
26
27
28
29
30
31
# 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) ⇒ Object



33
34
35
# File 'lib/benchmark/ips/stats/sd.rb', line 33

def speedup(baseline)
  baseline.slowdown(self)
end