iii ThreeTreesLight

about me / / /

[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




参考

http://qiita.com/items/f6ab4cf3c8541fc4da83?utm_source=Qiita+Newsletter+Users&utm_campaign=67f0866014-Qiita_newsletter_27_11_21_2012&utm_medium=email

2 years ago  Notes (1)
  1. threetreeslight posted this

#rails #tuning #refactoring