Saturday, June 28, 2008

Analyzing Rails Log Files for Slow Actions

There are plenty of packages for analyzing rails log files. These are helpful when you want to find bottlenecks in your application. A very easy to use one is rawk.rb discussed in Railscast #97. These tools are great as they help you to spend your efforts on the most costly areas of your code.

However, if you want to do a really quick, but less precise analysis of your code you can resort to some simple Unix tools as shown here:

This simple command line greps out the "Completed in" lines, cuts out the 3rd and 17th columns as separated by spaces, and then sorts the result. The two fields that have been cut out represent the number of seconds and URL for the action in question looking something like this:

9 seconds! Ouch!

Of course you can get much more advanced in the command line department with tools like awk but at that point you might as well download rawk.rb and get back to work.

No comments:

Post a Comment