Sha256: 0a475d252bcf4351b8275a2f6a20333f3305c4402f0adc70742eca8c7fc1183d

Contents?: true

Size: 1.67 KB

Versions: 207

Compression:

Stored size: 1.67 KB

Contents

class TestTimeRules

  # All tests to be imported will be passed to this method after they have been filtered.
  #
  # Whatever this method returns will be assigned as the rule to be used to work out how
  # that test scales from one target to another.
  def assign(name, attrs, options={})
    :constant
  end

  # This method will be called to evaluate the result of the rule for the reference target - 
  # that is the target used when importing an execution time profile.
  #
  # The rule name can be obtained from attrs["rule"]
  def evaluate(name, attrs, options={})
    rule = attrs["rule"]

    case rule
    when :constant
      1
    else
      raise "Rule not implemented - #{rule}"
    end
  end

  # This method will be called for each test to forecast what the time will be for the current
  # target, it must return a numeric value in all cases.
  #
  # The rule name can obtained from attrs["rule"] and the results from the reference target can
  # be obtained from attrs["reference"].
  #
  # The most basic way to forecast (and which could get you pretty far) is simply to ratio the rule
  # result for the reference target with the result from the current target, and then multiply
  # that by the reference time - an example of this is shown below.
  def forecast(name, attrs, options={})
    ref = attrs["reference"]

    val_for_current_target = evaluate(name, attrs, options)
    val_for_reference_target = ref["rule_result"]

    ref["time"] * (val_for_current_target / val_for_reference_target.to_f) # Force to a float so the
                                                                           # result is not an integer
  end

end

Version data entries

207 entries across 207 versions & 1 rubygems

Version Path
origen-0.7.38 templates/time/rules.rb.erb
origen-0.7.37 templates/time/rules.rb.erb
origen-0.7.36 templates/time/rules.rb.erb
origen-0.7.35 templates/time/rules.rb.erb
origen-0.7.34 templates/time/rules.rb.erb
origen-0.7.33 templates/time/rules.rb.erb
origen-0.7.32 templates/time/rules.rb.erb
origen-0.7.31 templates/time/rules.rb.erb
origen-0.7.30 templates/time/rules.rb.erb
origen-0.7.29 templates/time/rules.rb.erb
origen-0.7.28 templates/time/rules.rb.erb
origen-0.7.27 templates/time/rules.rb.erb
origen-0.7.26 templates/time/rules.rb.erb
origen-0.7.25 templates/time/rules.rb.erb
origen-0.7.24 templates/time/rules.rb.erb
origen-0.7.23 templates/time/rules.rb.erb
origen-0.7.22 templates/time/rules.rb.erb
origen-0.7.21 templates/time/rules.rb.erb
origen-0.7.20 templates/time/rules.rb.erb
origen-0.7.19 templates/time/rules.rb.erb