#98
Mar 24
Request Profiling
You can use profiling to determine where the performance bottlenecks are in specific Rails actions. Watch this episode for details.
Resources
# config/environments/staging.rb config.cache_classes = true config.action_controller.consider_all_requests_local = false config.action_controller.perform_caching = true config.action_view.cache_template_loading = true config.log_level = :debug # lib/products_index_profiler.rb get '/products' say "GET #{path}"
$ script/server -e staging $ sudo gem install ruby-prof $ RAILS_ENV=staging script/performance/request lib/products_index_profiler.rb



Good screencast. I'd like to see more information on how you can optimize things once you narrow down the culprits. Maybe a checklist of 'gotchas' or something like that. Especially any that are common and not well known.
Great screencast! Thank you very much for all this great information.
Thanks
Eddie Moses
Cool screencasts.. Thanks for sharing.
Little typo detected
should be:
sudo gem install ruby-prof
Great podcast, thanks for the info
@Sam:
its ruby-perf only. (perf => performance)
Nice screencast. I really need to measure performance issues of my app and tutorials like this are of great help. :)
@Carl, I did some previous episodes on optimization, but they don't cover everything so you can expect some more in the future. You can find them out here.
http://railscasts.com/tags/1
@Sam, thanks. Fixed.
Hey Ryan, Passenger (mod_rails) is looking for someone to redo there screencast before they release. I think you would be the perfect person for it.
check it out here...
http://izumi.plan99.net/blog/
@Taylor, thanks for the link. I'll look into doing it. :)
I'm able to run a script, but the files don't contain useful numbers. On Ubuntu (32bit), the first column of profile-flat contains a mix of inf and nan. I'll dig into this, but if you have some guidance, it would be greatly appreciated.
I've tried it on 32-bit Vista, 64-bit Ubuntu & 32-bit Ubuntu. They all report some sort of error. On 64-bit Ubuntu, it aborts with an Integer range error. On Vista, it complains that the files (txt & html) don't exist (though I can open them and see listings for all the methods with no timings). On 32bit Ubuntu, it complains twice about "Could not get a file descriptor referring to the console." These last two create files though the content lacks timings.
In the case of the discipline of pure reason, our a posteriori knowledge, then, teaches us nothing whatsoever regarding the content of the objects in space and time, as is evident upon close examination.
How do you get ruby-prof installed under osx? I've tried under both Tiger and Leopard and I get
No definition for prof_get_cpu_frequency
No definition for prof_set_cpu_frequency
on both