diff options
Diffstat (limited to 'activerecord/lib/active_record')
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 656258e49b..a79d75bba3 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -669,10 +669,17 @@ module ActiveRecord #:nodoc: # end def benchmark(title) result = nil + bm = Benchmark.measure { result = silence { yield } } + logger.info "#{title} (#{sprintf("%f", bm.real)})" + return result + end + + # Silences the logger for the duration of the block. + def silence + result = nil logger.level = Logger::ERROR - bm = Benchmark.measure { result = yield } + result = yield logger.level = Logger::DEBUG - logger.info "#{title} (#{sprintf("%f", bm.real)})" return result end |