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:
78 79 80 81 82 83 84 85 86 87 |
# File 'lib/custom_benchmarks.rb', line 78 def self.included(base) base.extend(ClassMethods) #if ENV['RAILS_ENV'] != "test" base.class_eval do alias_method :perform_action_without_custom_benchmark, :perform_action alias_method :perform_action, :perform_action_with_custom_benchmark end #end end |
Instance Method Details
#perform_action_with_custom_benchmark ⇒ Object
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/custom_benchmarks.rb', line 104 def perform_action_with_custom_benchmark unless logger perform_action_without_custom_benchmark else t1 = Time.now perform_action_without_custom_benchmark runtime = Time.now - t1 = ["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 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(.join(' ')) end end |