config/environments/benchmarking.rb
This is a separate Rails environment used for benchmarking. When created, it is
a copy of the production.rb file, but it can be customized to meet the benchmark??™s
needs.
Railsbench has a command to generate the config/benchmarks.yml file based on the
application??™s routes. We will run this to create the basic version of the file.
$ railsbench generate_benchmarks
We delete actions from this file that we do not need to benchmark (such as named
routes generated automatically by map.resources, some of which are unused). And
we modify the searches_create benchmark, changing the method to post and adding
the POST data we need:
searches_create:
uri: /searches/
action: create
controller: searches
method: post
post_data: "search[pclass]=1&search[city_id]=149&search[subtype]=HOUSE"
Rails Optimization Example | 163
There is one last change we must make. By default, all Rails environments except production
have a log level of :debug. We want to set the benchmarking environment??™s log
level to :info, so that we don??™t confound the benchmarking results with I/O issues from
heavy log traffic. Add the following line to config/environments/benchmarking.yml:
config.log_level = :info
Running the benchmark
Now we can run the benchmarks. We use the Railsbench perf_run command, which
takes as an argument the number of requests to make on each trial.
Pages:
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253