Module: ActionController::CustomBenchmarking
- Defined in:
- lib/custom_benchmarks.rb
Overview
:nodoc:
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
-
.included(base) ⇒ Object
:nodoc:.
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
:nodoc:
71 72 73 74 75 76 77 78 |
# File 'lib/custom_benchmarks.rb', line 71 def self.included(base) base.extend(ClassMethods) base.class_eval do alias_method :perform_action_without_custom_benchmark, :perform_action alias_method :perform_action, :perform_action_with_custom_benchmark end end |
Instance Method Details
#perform_action_with_custom_benchmark ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/custom_benchmarks.rb', line 93 def perform_action_with_custom_benchmark unless logger perform_action_without_custom_benchmark else runtime = [Benchmark::measure{ perform_action_without_custom_benchmark }.real, 0.0001].max = "Finished #{controller_class_name}\##{action_name} in #{sprintf("%.5f", runtime)} (#{(1 / runtime).floor} reqs/sec)" if Object.const_defined?("ActiveRecord") && ActiveRecord::Base.connected? << active_record_runtime(runtime) end << rendering_runtime(runtime) if @rendering_runtime self.class.custom_benchmarks.each do |benchmark| << benchmark.call(runtime) end << " | Time: #{Time.now.to_i}" << " | #{headers["Status"]}" << " [#{complete_request_uri rescue "unknown"}]" logger.info() end end |