Skip to content

Instantly share code, notes, and snippets.

@skanev
Created November 3, 2011 14:17
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skanev/1336588 to your computer and use it in GitHub Desktop.
Save skanev/1336588 to your computer and use it in GitHub Desktop.
Debugging the performance of a Rails controller action
require 'rails/console/app'
ActiveSupport::Notifications.subscribe /^sql\./ do |*args|
puts caller.grep(%r[/garmz/]) { |line| " #{line.gsub(/.*?\/garmz\//, '')}" }.take(3) * "\n"
end
ActiveRecord::Base.logger = Logger.new(STDOUT)
app.get '/newsfeed'
ActiveRecord::Base.logger = Logger.new(nil)
Benchmark.bm do |b|
b.report do
5.times { app.get '/newsfeed' }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment