lib/perfer/job/iteration_job.rb
def find_number_of_iterations_required(last_iterations = 1, last_time = 0)
      iterations = last_iterations
      if last_time > 0
        iterations = compute_new_iterations(last_iterations, last_time)
      end
      iterations = round_for_eval(iterations)
      puts "Start search for iterations: start=#{iterations}" if verbose
      loop do
        puts "iterations: #{iterations}" if verbose
        time = measure_call_times(iterations)[:real]
        break if time > minimal_time

        if time <= 0
          iterations *= 2
          next
        end

        new_iterations = compute_new_iterations(iterations, time)
        # ensure the number of iterations increases
        if new_iterations <= iterations
          puts "new_iterations <= iterations: #{new_iterations} <= #{iterations}" if verbose
          new_iterations = (iterations*1.5).ceil
        end
        if new_iterations > MAX_GROW_FACTOR * iterations
          new_iterations = MAX_GROW_FACTOR * iterations
        end
        iterations = round_for_eval(new_iterations)
      end
      puts "End search for iterations: iterations=#{iterations}" if verbose
      iterations
    end
# This factor ensure some margin,
# to avoid endlessly changing the number of iterations
This factor ensure some margin,
to avoid endlessly changing the number of iterations
This factor ensure some margin to avoid endlessly changing the number of iterations
def find_number_of_iterations_required(last_iterations = 1, last_time = 0)
      iterations = last_iterations
      if last_time > 0
        iterations = compute_new_iterations(last_iterations, last_time)
      end
      iterations = round_for_eval(iterations)
      puts "Start search for iterations: start=#{iterations}" if verbose
      loop do
        puts "iterations: #{iterations}" if verbose
        time = measure_call_times(iterations)[:real]
        break if time > minimal_time
        if time <= 0
          iterations *= 2
          next
        end
        new_iterations = compute_new_iterations(iterations, time)
        if new_iterations <= iterations
          puts "new_iterations <= iterations: #{new_iterations} <= #{iterations}" if verbose
          new_iterations = (iterations*1.5).ceil
        end
        if new_iterations > MAX_GROW_FACTOR * iterations
          new_iterations = MAX_GROW_FACTOR * iterations
        end
        iterations = round_for_eval(new_iterations)
      end
      puts "End search for iterations: iterations=#{iterations}" if verbose
      iterations
    end
def find_number_of_iterations_required ( last_iterations = 1 , last_time = 0 ) iterations = last_iterations if last_time > 0 iterations = compute_new_iterations ( last_iterations , last_time ) end iterations = round_for_eval ( iterations ) puts "Start search for iterations: start=#{iterations}" if verbose loop do puts "iterations: #{iterations}" if verbose time = measure_call_times ( iterations ) [ :real ] break if time > minimal_time if time <= 0 iterations *= 2 next end new_iterations = compute_new_iterations ( iterations , time ) if new_iterations <= iterations puts "new_iterations <= iterations: #{new_iterations} <= #{iterations}" if verbose new_iterations = ( iterations * 1.5 ) . ceil end if new_iterations > MAX_GROW_FACTOR * iterations new_iterations = MAX_GROW_FACTOR * iterations end iterations = round_for_eval ( new_iterations ) end puts "End search for iterations: iterations=#{iterations}" if verbose iterations end
This factor ensure some margin,
to avoid endlessly changing the number of iterations
This factor ensure some margin to avoid endlessly changing the number of iterations
# ensure the number of iterations increases
last_iterations
last_time