require 'repeating_benchmark' class ActionController::Base def perform_action if self.class.action_methods.include?(action_name) if $perform_action_with_benchmark if defined?(JRUBY_VERSION) require 'rbconfig' val = nil Dir.chdir(Config::CONFIG['prefix']) do val = `svn info` end /Revision: (\d+)/ =~ val rev = $1 /Last Changed Date: (.+)$/ =~ val date = $1 RepeatingBenchmark.log("== JRuby r#{rev} (from #{date})") else RepeatingBenchmark.log("== MRI") end RepeatingBenchmark.log("==== env: #{RAILS_ENV}") RepeatingBenchmark.log("#{self.class}##{action_name}") RepeatingBenchmark.report('controller ') { send(action_name) } RepeatingBenchmark.report('view ') { @performed_render = false; response.body = ''; render } unless performed? else send(action_name) render unless performed? end elsif respond_to? :method_missing send(:method_missing, action_name) render unless performed? elsif template_exists? && template_public? render else raise UnknownAction, "No action responded to #{action_name}", caller end end end $perform_action_with_benchmark = true app.get '/shop/viewCategory.shtml?category=DOGS' $perform_action_with_benchmark = false RepeatingBenchmark.report('full action') { app.get '/shop/viewCategory.shtml?category=DOGS' } puts File.readlines("#{RAILS_ROOT}/log/benchmark.log")[-41..-1]