# File vendor/rails/activesupport/lib/active_support/testing/performance.rb, line 26
26: def self.included(base)
27: base.superclass_delegating_accessor :profile_options
28: base.profile_options = DEFAULTS
29: end
# File vendor/rails/activesupport/lib/active_support/testing/performance.rb, line 31
31: def full_test_name
32: "#{self.class.name}##{method_name}"
33: end
# File vendor/rails/activesupport/lib/active_support/testing/performance.rb, line 35
35: def run(result)
36: return if method_name =~ /^default_test$/
37:
38: yield(self.class::STARTED, name)
39: @_result = result
40:
41: run_warmup
42: if profile_options && metrics = profile_options[:metrics]
43: metrics.each do |metric_name|
44: if klass = Metrics[metric_name.to_sym]
45: run_profile(klass.new)
46: result.add_run
47: end
48: end
49: end
50:
51: yield(self.class::FINISHED, name)
52: end
# File vendor/rails/activesupport/lib/active_support/testing/performance.rb, line 54
54: def run_test(metric, mode)
55: run_callbacks :setup
56: setup
57: metric.send(mode) { __send__ @method_name }
58: rescue ::Test::Unit::AssertionFailedError => e
59: add_failure(e.message, e.backtrace)
60: rescue StandardError, ScriptError
61: add_error($!)
62: ensure
63: begin
64: teardown
65: run_callbacks :teardown, :enumerator => :reverse_each
66: rescue ::Test::Unit::AssertionFailedError => e
67: add_failure(e.message, e.backtrace)
68: rescue StandardError, ScriptError
69: add_error($!)
70: end
71: end
# File vendor/rails/activesupport/lib/active_support/testing/performance.rb, line 84
84: def run_profile(metric)
85: klass = profile_options[:benchmark] ? Benchmarker : Profiler
86: performer = klass.new(self, metric)
87:
88: performer.run
89: puts performer.report
90: performer.record
91: end