aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib')
-rwxr-xr-xactiverecord/lib/active_record/base.rb16
1 files changed, 11 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 6180f45fed..a6ce28685c 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -714,11 +714,17 @@ module ActiveRecord #:nodoc:
# project.create_manager("name" => "David")
# project.milestones << Milestone.find(:all)
# end
- def benchmark(title)
- result = nil
- seconds = Benchmark.realtime { result = silence { yield } }
- logger.info "#{title} (#{sprintf("%f", seconds)})" if logger
- return result
+ #
+ # The loggings of the multiple statements is turned off unless <tt>use_silence</tt> is set to false.
+ def benchmark(title, use_silence = true)
+ if logger
+ result = nil
+ seconds = Benchmark.realtime { result = use_silence ? silence { yield } : yield }
+ logger.info "#{title} (#{sprintf("%f", seconds)})"
+ result
+ else
+ yield
+ end
end
# Silences the logger for the duration of the block.