<p>What is the best way to profile a controller action in Ruby on Rails. Currently I am using the brute-force method of throwing in <code>puts Time.now</code> calls between what I think will be a bottleneck. But that feels really, really dirty. There has got to be a better way.</p>

Use the Benchmark standard library and the various tests available in Rails (unit, functional, integration). Here's an example:
```
```
def test_do_something
  elapsed_time = Benchmark.realtime do
    100.downto(1) do |index|
      # do something here
    end
  end
  assert elapsed_time < SOME_LIMIT
end
```
```
So here we just do something 100 times, time it via the Benchmark library, and ensure that it took less than SOME_LIMIT amount of time.
You also may find these links useful: The
Benchmark.realtime reference
and the
Test::Unit reference
. Also, if you're into the 'book reading' thing, I picked up the idea for the example from
Agile Web Development with Rails
, which talks all about the different testing types and a little on performance testing.