aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/metal
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2009-10-09 09:52:25 -0300
committerJosé Valim <jose.valim@gmail.com>2009-10-15 18:19:25 -0300
commita15e02d44ac2afb27a7e8e652c98a796d271b645 (patch)
tree4c9dabe41390eff440bfa3f24b5a153d644569c9 /actionpack/lib/action_controller/metal
parentaeaabc6d2d6f9faaa98057f33c0635d8add54461 (diff)
downloadrails-a15e02d44ac2afb27a7e8e652c98a796d271b645.tar.gz
rails-a15e02d44ac2afb27a7e8e652c98a796d271b645.tar.bz2
rails-a15e02d44ac2afb27a7e8e652c98a796d271b645.zip
Unify benchmark APIs.
Diffstat (limited to 'actionpack/lib/action_controller/metal')
-rw-r--r--actionpack/lib/action_controller/metal/benchmarking.rb23
1 files changed, 2 insertions, 21 deletions
diff --git a/actionpack/lib/action_controller/metal/benchmarking.rb b/actionpack/lib/action_controller/metal/benchmarking.rb
index d4cb1e122d..e58df69172 100644
--- a/actionpack/lib/action_controller/metal/benchmarking.rb
+++ b/actionpack/lib/action_controller/metal/benchmarking.rb
@@ -1,4 +1,4 @@
-require 'benchmark'
+require 'active_support/core_ext/benchmark'
module ActionController #:nodoc:
# The benchmarking module times the performance of actions and reports to the logger. If the Active Record
@@ -6,25 +6,6 @@ module ActionController #:nodoc:
module Benchmarking #:nodoc:
extend ActiveSupport::Concern
- module ClassMethods
- # Log and benchmark the workings of a single block and silence whatever logging that may have happened inside it
- # (unless <tt>use_silence</tt> is set to false).
- #
- # The benchmark is only recorded if the current level of the logger matches the <tt>log_level</tt>, which makes it
- # easy to include benchmarking statements in production software that will remain inexpensive because the benchmark
- # will only be conducted if the log level is low enough.
- def benchmark(title, log_level = Logger::DEBUG, use_silence = true)
- if logger && logger.level == log_level
- result = nil
- ms = Benchmark.ms { result = use_silence ? silence { yield } : yield }
- logger.add(log_level, "#{title} (#{('%.1f' % ms)}ms)")
- result
- else
- yield
- end
- end
- end
-
protected
def render(*args, &block)
if logger
@@ -45,7 +26,7 @@ module ActionController #:nodoc:
else
super
end
- end
+ end
private
def process_action(*args)