New to Rails 3? Check out the Ruby on Rails 3 Tutorial book and screencast.

A book and screencast series showing you how to develop and deploy industrial-strength Rails apps in a direct, step by step way. The screencast series includes 12 lessons over more than 15 hours! Get the best "over the shoulder" experience of following what a top Rails 3 developer does when building an app today. Click here to learn more.

Rails Profiling: Getting Easier

In Tools

profiler-crop2.pngLast year we looked at using ruby-prof to gather profiling data for a Rails application. But it's worth revisiting the subject now that ruby-prof 0.7.0 is out: gathering profile test data for a Rails application is almost absurdly easy now.

As detailed by gem author Charlie Savage, hooking everything up begins with creating a profile environment for your Rails application. Sprinkle in a new test helper (that comes with the gem), include RubyProf::Test in your tests, save them to test/profile, and just execute them like any other tests.

The results? A quick summary in the output is just the tip of the iceberg:

MyControllerTest#test_get (0.01s warmup)
..........
process_time: 0.11 seconds
.
Finished in 0.509442 seconds.

You also get text and HTML reports with detailed information, including the number of times each method is called, how long they took, and links back into your source code. There are still problems to be solved - notably, how to track changes in performance over time - but the basic process of measuring the performance of a Rails application in a repeatable way can now be regarded as finished.

Post to Twitter Tweet This Post

Vaguely Related Posts (Usually)

One Comment Response to “Rails Profiling: Getting Easier”

  1. #1
    Richard Poirier Says:

    Are there any advantages to using this over New Relic RPM?

Leave a Reply