In this third article on performance optimization for Ruby on Rails applications, you'll learn how to run the Action Profiler tool and how to start using caching to improve your application's performance. This article is excerpted from chapter 13 of the book Practical Rails Projects, written by Eldon Alameda (Apress; ISBN: 1590597818).
You can see from the output that about half of the time is spent scanning strings and creating path names. However, since the built-in profiler presents everything in a flat output, it is hard to know in which part of the application code the time is actually spent. If you want output with call graphs to see where different methods are called from, consider installing ruby-prof.
Note There are currently some compatibility issues between the Action Profiler and both ZenProfiler and ruby-prof. We hope they will be resolved by the time this book hits the shelves.
Another tool for measuring Rails application performance is Railsbench by Rails performance expert Stefan Kaes. You can download if from http://railsbench.rubyforge.org/.
If you’re working on Windows, you might find Railsbench more useful than the Action Profiler. By default, it uses the Windows-only Ruby Performance Validator (www.softwareverify.com/ruby/profiler/ index.html), which is said to be the best Ruby profiler around.