class Object
Public Instance Methods
display_time(prc, trials)
click to toggle source
Helper method to get time required for method to run Returns time in seconds
# File lib/algorithm_selector.rb, line 546 def display_time(prc, trials) total = 0 trials.times do start = Time.now prc.call finish = Time.now total = total + (finish - start) end total/trials end
merge(left, right)
click to toggle source
Helper method for merge_sort
# File lib/algorithm_selector.rb, line 558 def merge(left, right) data_set = [] until left.length == 0 || right.length == 0 if left.first > right.first data_set << right.shift else data_set << left.shift end end data_set.concat(left).concat(right) end