module CopperWire def self.append_features(base) super base.after_filter :show_runtimes base.around_filter { |controller, action| controller.total_runtime = Benchmark.measure(&action).real } end end module ActionController class Base attr_accessor :total_runtime def show_runtimes return if response.headers['Status'] == '304 Not Modified' || !(response.body && response.body.respond_to?(:sub!)) db_runtime = ((0 + (@db_rt_before_render || 0) + (@db_rt_after_render || 0)) * 1000).truncate rendering_runtime = ((@rendering_runtime || 0) * 1000).truncate total_runtime = ((@total_runtime || 0) * 1000).truncate response.body.gsub!(/<\/body>$/, "\n") end end end