-
-
Save k41n/e96540b807946199ca86b9d65ca11dd3 to your computer and use it in GitHub Desktop.
Profile rails controller with ruby-prof
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # gem "ruby-prof" | |
| around_filter :profiler | |
| def profiler(&block) | |
| data = RubyProf::Profile.profile(&block) | |
| filepath = Rails.root.join("tmp", "profiler.html") | |
| File.open(filepath, "w") do |f| | |
| RubyProf::CallStackPrinter.new(data).print(f) | |
| end | |
| Rails.logger.debug "Profiler results saved to #{filepath}" | |
| system "open #{filepath}" | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment