test_script.rb
post '/searches', :search => {:pclass => 1, :city_id => 149, :subtype => 'HOUSE'}
We can drive the profiler with this script. We will also specify the number of trials;
this is a fairly long-running action (around half a second on my machine without the
profiling overhead), so we will run 10 trials:
$ script/performance/request -n 10 test_script.rb
This will generate two profiles in the tmp directory (and open them using open on
OS X). The flat profile, which we have seen before, is tmp/profile-flat.txt. The new
graph profile, which is much more detailed, is tmp/profile-graph.html.
The graph profile is extremely complicated, because it is a linearized version of the
call graph for every function that was called during profiling. When opened in a
browser, it starts off as shown in Figure 6-2.
We will examine portions of this graph, but a complete description of these fields is
beyond the scope of this book. An introduction is available at http://ruby-prof.
rubyforge.org/graph.txt.
The profile is divided into blocks, which are separated by horizontal lines. Each
block in this profile is centered around one function??”the one in boldface that has
values in the first two columns (%Total and %Self ). If we only look at that one line
from each block, we have a fairly standard flat profile, like the one we saw previously
from Ruby??™s Profiler. The %Total column indicates the percentage of overall
time spent in this method and any methods it calls (and recursively on down); the
%Self column excludes children and only relates to the current method.
Pages:
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244