提交 4bcd64c9 编写于 作者: J Jeremy Kemper

Ruby 1.9 compat: switch profile_options to superclass_delegating_accessor

上级 a445cdd8
...@@ -17,14 +17,14 @@ module Performance ...@@ -17,14 +17,14 @@ module Performance
else else
{ :benchmark => false, { :benchmark => false,
:runs => 1, :runs => 1,
:min_percent => 0.02, :min_percent => 0.01,
:metrics => [:process_time, :memory, :objects], :metrics => [:process_time, :memory, :objects],
:formats => [:flat, :graph_html, :call_tree], :formats => [:flat, :graph_html, :call_tree],
:output => 'tmp/performance' } :output => 'tmp/performance' }
end end.freeze
def self.included(base) def self.included(base)
base.class_inheritable_hash :profile_options base.superclass_delegating_accessor :profile_options
base.profile_options = DEFAULTS base.profile_options = DEFAULTS
end end
...@@ -34,16 +34,17 @@ def full_test_name ...@@ -34,16 +34,17 @@ def full_test_name
def run(result) def run(result)
return if method_name =~ /^default_test$/ return if method_name =~ /^default_test$/
self.profile_options ||= DEFAULTS
yield(self.class::STARTED, name) yield(self.class::STARTED, name)
@_result = result @_result = result
run_warmup run_warmup
profile_options[:metrics].each do |metric_name| if profile_options && metrics = profile_options[:metrics]
if klass = Metrics[metric_name.to_sym] metrics.each do |metric_name|
run_profile(klass.new) if klass = Metrics[metric_name.to_sym]
result.add_run run_profile(klass.new)
result.add_run
end
end end
end end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册