Shiny happy people coding

Coding with smile

Profile a Request in Rails

| Comments

To found the bug that speak before , I would made a request profiling to know where a long time is spend during the rendering of this page

How using the script Request Profiler

Since Rails 2.0, there are a new script, script/performance/request. This script made a profile on one or several internet requests.

To define the request, you just need write a script like an integration test. This example come from rails's changelog.

get_with_redirect '/' say "GET / => #{path}" post_with_redirect '/sessions', :username => 'john', :password => 'doe' say "POST /sessions => #{path}"

Once script created, launch the script with number of request made in option

$ ./script/performance/request -n 10 login_session.rb

But there are no system (for me) to define session values in start. Before, you made the login connection by example, if you want a user connected

Incompatibility between Rails 2.1 and ruby-prof

So the Living on the Edge speak about add new script needeed ruby-prof-0.6.1, I thought it's the alone need ruby-prof-0.6.1. This version doesn't exist in rubyforge yet (last version is 0.6.0). But it's not true. Since rails 2.1, the script performance/request need too ruby-prof-0.6.1. But this version is not release yet. You need to make and to install this gem to add this functionnality. In fact, even if you update rails code, doesn't check the ruby-prof gem version, the version 0.6.0 haven't all methode needed.

Make and install ruby-prof-0.6.1

You need get sources since ruby-prof svn

svn co http://ruby-prof.rubyforge.org/svn/

After, you generate the gem

$ rake package

In end, you can install the gem

# gem install pkg/ruby-prof-0.6.1.gem

Now, you have ruby-prof-0.6.1 install in you system and you can use the script performance/request.

Traduction fran├žaise