Skip to content
ngauthier edited this page Sep 13, 2010 · 2 revisions

Hydra uses ruby-prof for profiling.

Why is this better than ruby-prof

First of all, it is ruby prof! But when you use ruby prof, you have to run it around a chunk of code. Rails comes with some helpers for this, and they are great at telling you what is slow about a single isolated chunk of code.

But running ruby-prof on Hydra means you get one combined report for all of your tests (across all your frameworks) that aggregates the results of ruby-prof for you.

Setting up the Rake Task

Setting up a profile task is just like setting up a test task, except you get a few new options:

Hydra::ProfileTask.new('hydra:prof') do |t|
  t.add_files 'test/unit/**/*_test.rb'
  t.add_files 'test/functional/**/*_test.rb'
  t.add_files 'test/integration/**/*_test.rb'
  t.generate_html = true # defaults to false
  t.generate_text = true # defaults to true
  # put any setup you don't want to profile here
  # useful for removing environment load from the output
  require 'test/test_helper.rb'
  # or spec helper or anything else
end

generate_html

Choose whether or not to generate an HTML report. HTML reports are more detailed, but they take longer to produce. Off by default.

generate_text

Choose whether or not the generate a text report. On by default.

Interpreting the results

Ruby-Prof’s Documentation

Scroll down to the Reports section and check out their examples.