Skip to content

Instantly share code, notes, and snippets.

@eamonn-webster
Created April 29, 2013 15:22
Show Gist options
  • Save eamonn-webster/5482299 to your computer and use it in GitHub Desktop.
Save eamonn-webster/5482299 to your computer and use it in GitHub Desktop.
Using rack-mini-profiler
# Gemfile
# gem 'rack-mini-profiler'
# config/environment.rb
if Rails.env.development?
# profile all middleware
Qstream::Application.middleware.each do |mw|
begin
::Rack::MiniProfiler.profile_method(mw.klass, :call) {|app| "#{mw.klass} call"}
rescue
puts "Unable to profile #{mw.klass}"
end
end
# other bits and pieces
::Rack::MiniProfiler.profile_method(ActionDispatch::Routing::RouteSet::Dispatcher, :call) {|app| "ActionDispatch::Routing::RouteSet::Dispatcher#call"}
::Rack::MiniProfiler.profile_method(ActionDispatch::Routing::RouteSet::Dispatcher, :controller) {|app| "ActionDispatch::Routing::RouteSet::Dispatcher#controller"}
::Rack::MiniProfiler.profile_method(ActionDispatch::Routing::RouteSet::Dispatcher, :controller_reference) {|app| "ActionDispatch::Routing::RouteSet::Dispatcher#controller_reference"}
::Rack::MiniProfiler.profile_method(ActionDispatch::Routing::RouteSet::Dispatcher, :dispatch) {|app| "ActionDispatch::Routing::RouteSet::Dispatcher#dispatch"}
::Rack::MiniProfiler.profile_method(ActiveSupport::Dependencies::ClassCache, :get) {|key| "ActiveSupport::Dependencies::ClassCache#get #{key.respond_to?(:name) ? key.name : key }"}
::Rack::MiniProfiler.profile_method(UsersController, :dashboard) {|| "UsersController#dashboard"}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment