DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

FInd Slow Actions In A Rails App

08.21.2007
| 3170 views |
  • submit to reddit
        
# Show a list of actions sorted by time taken. Useful for finding slow actions.
cat log/development.log | awk '/Completed/ { print "[" $3 "] - " $0 }' | sort -nr
    

Comments

Snippets Manager replied on Sun, 2006/12/31 - 12:43am

The -n flag on the sort command sorts by numeric rather than by character. It works on my box (Linux/Gentoo) Then again, I don't have anything beyond double digits in the test log. This line can be added to a script, such as script/analyze_logs for convenience. -Q

Joe Martinez replied on Tue, 2006/01/10 - 11:24pm

This is cool but doesn't sort exactly right - it only sorts by the first digit in the completion time - report actions taking in the double digits don't fall in line. I guess that's motivation to get all actions in the single digits :)