Wednesday, December 19, 2007

Installing and running Railsbench for your Ruby on Rails application

Installation of railsbench on Windows

  1. run from any directory (no download required) gem install hoe (this installs dependency gem hoe).
  2. Download railsbench gem from RubyForge and run gem install railsbench-0.9.2.gem from the directory where it is downloaded.
  3. Run gem list to see railsbench version 0.9.2 listed.

Running railsbench on Windows
  1. Set environment variable RAILS_ROOT through control panel to point to your app directory (here guitarati)
    RAILS_ROOT set to C:\InstantRails\rails_apps\guitarati
  2. Railsbench writes the result of tests in RAILS_PERF_DATA directory. Set environment variable RAILS_PERF_DATA through control panel. I chose to save the data in a newly created directory perf_data under RAILS_ROOT.
    RAILS_PERF_DATA set to C:\InstantRails\rails_apps\guitarati\perf_data
  3. Copy benchmarks.yml and benchmarking.rb from C:\InstantRails\ruby\lib\ruby\gems\1.8\gems\railsbench-0.9.2\config to RAILS_ROOT\config
  4. Copy benchmarking.rb from C:\InstantRails\ruby\lib\ruby\gems\1.8\gems\railsbench-0.9.2\config to RAILS_ROOT\config\environments
  5. run railsbench install from C:\InstantRails\ruby\lib\ruby\gems\1.8\gems\railsbench-0.9.2 directory. Should output .. creating database configuration: benchmarking
  6. Edit environment.rb to specify the plugins to be loaded:
    config.plugins = %W( simple_captcha acts_as_ferret ...etc...). Without this, running railsbench perf_run gives undefined method errors for me.
  7. Run the simplest railsbench command
    C:\...\1.8\gems\railsbench-0.9.2>railsbench perf_run 100
  8. The above command prints something like this



  9. Understanding the railsbench results is a topic in itself to be covered in a later blog post.

0 comments: