lib/perfer/job/iteration_job.rb
def run
      super
      measurements = []

      # Run one iteration, so system-level buffers and other OS warm-up can take place
      # This is usually a very inaccurate measurement, so just discard it
      measure_call_times(round_for_eval(1))

      iterations = find_number_of_iterations_required

      measurements_taken = 0
      until measurements.size == number_of_measurements and
            mad(measurements) < 0.01 * measurements_taken / number_of_measurements
        time = measure_call_times(iterations)
        measurements_taken += 1
        if time[:real] < (1.0 - CHANGE_ITERATIONS_MARGIN) * minimal_time
          # restart and find a more appropriate number of iterations
          puts "Restarting, #{time[:real]} < #{minimal_time}" if verbose
          measurements.clear
          measurements_taken = 0
          iterations = find_number_of_iterations_required(iterations, time[:real])
        else
          # circular buffer needed!
          measurements.shift if measurements.size == number_of_measurements
          measurements << time
        end
      end

      result = Result.new(@metadata)
      result[:iterations] = iterations
      result.data = measurements
      @session.add_result(result)
    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 run
      super
      measurements = []
      measure_call_times(round_for_eval(1))
      iterations = find_number_of_iterations_required
      measurements_taken = 0
      until measurements.size == number_of_measurements and
            mad(measurements) < 0.01 * measurements_taken / number_of_measurements
        time = measure_call_times(iterations)
        measurements_taken += 1
        if time[:real] < (1.0 - CHANGE_ITERATIONS_MARGIN) * minimal_time
          puts "Restarting, #{time[:real]} < #{minimal_time}" if verbose
          measurements.clear
          measurements_taken = 0
          iterations = find_number_of_iterations_required(iterations, time[:real])
        else
          measurements.shift if measurements.size == number_of_measurements
          measurements << time
        end
      end
      result = Result.new(@metadata)
      result[:iterations] = iterations
      result.data = measurements
      @session.add_result(result)
    end
def run super measurements = [ ] measure_call_times ( round_for_eval ( 1 ) ) iterations = find_number_of_iterations_required measurements_taken = 0 until measurements . size == number_of_measurements and mad ( measurements ) < 0.01 * measurements_taken / number_of_measurements time = measure_call_times ( iterations ) measurements_taken += 1 if time [ :real ] < ( 1.0 - CHANGE_ITERATIONS_MARGIN ) * minimal_time puts "Restarting, #{time[:real]} < #{minimal_time}" if verbose measurements . clear measurements_taken = 0 iterations = find_number_of_iterations_required ( iterations , time [ :real ] ) else measurements . shift if measurements . size == number_of_measurements measurements << time end end result = Result . new ( @metadata ) result [ :iterations ] = iterations result . data = measurements @session . add_result ( result ) 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
# Run one iteration, so system-level buffers and other OS warm-up can take place # This is usually a very inaccurate measurement, so just discard it # restart and find a more appropriate number of iterations # circular buffer needed!