Namespace
Methods
F
I
R
Constants
DEFAULTS = if benchmark = ARGV.include?('--benchmark') # HAX for rake test { :benchmark => true, :runs => 4, :metrics => [:wall_time, :memory, :objects, :gc_runs, :gc_time], :output => 'tmp/performance' } else { :benchmark => false, :runs => 1, :min_percent => 0.01, :metrics => [:process_time, :memory, :objects], :formats => [:flat, :graph_html, :call_tree], :output => 'tmp/performance' } end.freeze
 
Class Public methods
included(base)
# File activesupport/lib/active_support/testing/performance.rb, line 26
def self.included(base)
  base.class_attribute :profile_options
  base.profile_options = DEFAULTS
end
Instance Public methods
full_test_name()
# File activesupport/lib/active_support/testing/performance.rb, line 31
def full_test_name
  "#{self.class.name}##{method_name}"
end
run(result)
# File activesupport/lib/active_support/testing/performance.rb, line 35
def run(result)
  return if method_name =~ /^default_test$/
  yield(self.class::STARTED, name)
  @_result = result
  run_warmup
  if profile_options && metrics = profile_options[:metrics]
    metrics.each do |metric_name|
      if klass = Metrics[metric_name.to_sym]
        run_profile(klass.new)
        result.add_run
      end
    end
  end
  yield(self.class::FINISHED, name)
end
run_test(metric, mode)
# File activesupport/lib/active_support/testing/performance.rb, line 54
def run_test(metric, mode)
  run_callbacks :setup
  setup
  metric.send(mode) { __send__ @method_name }
rescue ::Test::Unit::AssertionFailedError => e
  add_failure(e.message, e.backtrace)
rescue StandardError, ScriptError
  add_error($!)
ensure
  begin
    teardown
    run_callbacks :teardown, :enumerator => :reverse_each
  rescue ::Test::Unit::AssertionFailedError => e
    add_failure(e.message, e.backtrace)
  rescue StandardError, ScriptError
    add_error($!)
  end
end
Instance Protected methods
run_profile(metric)
# File activesupport/lib/active_support/testing/performance.rb, line 84
def run_profile(metric)
  klass = profile_options[:benchmark] ? Benchmarker : Profiler
  performer = klass.new(self, metric)
  performer.run
  puts performer.report
  performer.record
end
run_warmup()
# File activesupport/lib/active_support/testing/performance.rb, line 74
def run_warmup
  GC.start
  time = Metrics::Time.new
  run_test(time, :benchmark)
  puts "%s (%s warmup)" % [full_test_name, time.format(time.total)]
  GC.start
end