[rails][refactoring]railsのボトルネック探しツール
railsを実装しているときに、N+1問題回避するためにincludeしたり、処理をかき変えたりするが、やるんだったら最小で最大の効果を上げたい。
むしろ意味の無い所のチューニングには時間を費やしたくない。
そんなときにお薦めなツールをQiitaで見つけたのでご紹介
miniprofiler
各ページ表示やSQLの処理時間を計測し、表示してくれるツール。
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :miniprofiler
private
def miniprofiler
if Rails.env.development? || (current_user.try(:role) == "admin")
Rack::MiniProfiler.authorize_request
end
end
end
http://railscasts.com/episodes/368-miniprofiler?view=asciicast
bullet
N+1問題が発生しているSQLをlog/bullet.logに吐いてくれる
Gemfile
group :development
+ gem "bullet"
end
https://github.com/flyerhzm/bullet
http://railscasts.com/episodes/372-bullet
参考
takayukiatkwsk likes this
threetreeslight posted this