class Benchmarker::Result

Public Class Methods

new() click to toggle source
# File lib/benchmarker.rb, line 615
def initialize()
  @iterations = []
end

Public Instance Methods

[](idx) click to toggle source
# File lib/benchmarker.rb, line 619
def [](idx)
  return @iterations[idx]
end
add(timeset) click to toggle source
# File lib/benchmarker.rb, line 631
def add(timeset)
  #; [!thyms] adds timeset and returns self.
  @iterations << timeset
  self
end
calc_average() click to toggle source
# File lib/benchmarker.rb, line 670
def calc_average()
  #; [!b91w3] returns average of timeddata.
  user = sys = total = real = 0.0
  @iterations.each do |t|
    user  += t.user
    sys   += t.sys
    total += t.total
    real  += t.real
  end
  n = @iterations.length
  return TimeSet.new(user/n, sys/n, total/n, real/n)
end
clear() click to toggle source
# File lib/benchmarker.rb, line 637
def clear()
  #; [!fxrn6] clears timeset array.
  @iterations.clear()
  self
end
each(&b) click to toggle source
# File lib/benchmarker.rb, line 627
def each(&b)
  @iterations.each(&b)
end
length() click to toggle source
# File lib/benchmarker.rb, line 623
def length()
  return @iterations.length
end
remove_minmax(extra, key=:real) click to toggle source
# File lib/benchmarker.rb, line 652
def remove_minmax(extra, key=:real)
  #; [!b55zh] removes best and worst timeset and returns them.
  i = 0
  pairs = @iterations.collect {|t| [t, i+=1] }
  pairs = pairs.sort_by {|pair| pair[0].__send__(key) }
  removed = []
  extra.times do
    min_timeset, min_idx = pairs.shift()
    max_timeset, max_idx = pairs.pop()
    min_t = min_timeset.__send__(key)
    max_t = max_timeset.__send__(key)
    removed << [min_t, min_idx, max_t, max_idx]
  end
  remained = pairs.sort_by {|_, i| i }.collect {|t, _| t }
  @iterations = remained
  return removed
end
skipped=(reason) click to toggle source
# File lib/benchmarker.rb, line 643
def skipped=(reason)
  @reason = reason
end
skipped?() click to toggle source
# File lib/benchmarker.rb, line 647
def skipped?
  #; [!bvzk9] returns true if reason has set, or returns false.
  return !!@reason
end