Class: YARD::Bench::Marks::Mark

Inherits:
Object
  • Object
show all
Defined in:
lib/dsl/bm_dsl.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(times, memory) ⇒ Mark

Returns a new instance of Mark.



19
20
21
22
23
24
25
26
# File 'lib/dsl/bm_dsl.rb', line 19

def initialize(times, memory)
  @times = times
  @memory = memory
  @ok = !@times.nil? && !@memory.nil?
  normalized_times = @times.inject([]) { |agg, e| agg << (e.values[0] / (10**agg.size)) }
  @deviation = normalized_times.standard_deviation * 100 / normalized_times.mean
  @power = normalized_times.mean / @times[0].keys[0] * 1_000_000 if @ok && @deviation < 20
end

Instance Attribute Details

#deviationObject (readonly)

Returns the value of attribute deviation.



18
19
20
# File 'lib/dsl/bm_dsl.rb', line 18

def deviation
  @deviation
end

#memoryObject (readonly)

Returns the value of attribute memory.



18
19
20
# File 'lib/dsl/bm_dsl.rb', line 18

def memory
  @memory
end

#okObject (readonly)

Returns the value of attribute ok.



18
19
20
# File 'lib/dsl/bm_dsl.rb', line 18

def ok
  @ok
end

#powerObject (readonly)

Returns the value of attribute power.



18
19
20
# File 'lib/dsl/bm_dsl.rb', line 18

def power
  @power
end

#timesObject (readonly)

Returns the value of attribute times.



18
19
20
# File 'lib/dsl/bm_dsl.rb', line 18

def times
  @times
end