#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.
Download (33.6 MB, 10:53)
alternative download for iPod & Apple TV (20.1 MB, 10:53)
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

11 comments:

Carl Mar 24, 2008 at 12:36

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.


eddiemoses81@yahoo.com Mar 24, 2008 at 22:52

Great screencast! Thank you very much for all this great information.

Thanks
Eddie Moses


myspace proxy Mar 25, 2008 at 08:38

Cool screencasts.. Thanks for sharing.


Sam Mar 27, 2008 at 16:10

Little typo detected

should be:
sudo gem install ruby-prof

Great podcast, thanks for the info


AJ Mar 27, 2008 at 20:42

@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. :)


Ryan Bates Mar 29, 2008 at 10:34

@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.


Taylor Redden Mar 29, 2008 at 11:47

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/


Ryan Bates Mar 29, 2008 at 16:51

@Taylor, thanks for the link. I'll look into doing it. :)


JWBnyc Apr 11, 2008 at 16:48

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.


kino May 23, 2008 at 01:53

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.


Phil Jul 18, 2008 at 05:04

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

Add your comment:

(required)

(not displayed)

(SKIP THIS ONE)


(required)

subscribe:
sponsored by:
if you want to help:
required:
Get Quicktime Player