Home arrow Ruby-on-Rails arrow The Action Profiler and Performance Optimization
RUBY-ON-RAILS

The Action Profiler and Performance Optimization


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).

Author Info:
By: Apress Publishing
Rating: 5 stars5 stars5 stars5 stars5 stars / 4
December 08, 2010
TABLE OF CONTENTS:
  1. · The Action Profiler and Performance Optimization
  2. · Caching

print this article
SEARCH DEVARTICLES

The Action Profiler and Performance Optimization
(Page 1 of 2 )

Running the Action Profiler

The Action Profiler can profile a single Rails action call. It works with any of the three profiler tools for *nix machines: the built-in Ruby profiler, ruby-prof (http://ruby-prof.rubyforge.org/), or ZenProfiler (http://rubyforge.org/projects/zenhacks/). If you want to use ruby-prof or ZenProfiler, you need to install it first.

Here’s an example of running the Action Profiler with the built-in profiler against theshowaction inCatalogController:

$ action_profiler -P Profiler CatalogController#show

--------------------------------------------Warmup...

Profiling...

%

cumulative

self

 

self

total

 

time

seconds

seconds

calls

ms/call

ms/call

name

26.98

1.02

1.02

204

5.00

6.37

String#scan

12.17

1.48

0.46

408

1.13

1.94

Pathname#initialize

10.32

1.87

0.39

204

1.91

11.62

Pathname#cleanpath_aggressive

5.82

2.09

0.22

424

0.52

2.52

Class#new

5.56

2.30

0.21

2587

0.08

0.08

String#==

4.50

2.47

0.17

306

0.56

10.52

String#gsub

3.70

2.61

0.14

614

0.23

0.44

Kernel.dup

3.44

2.74

0.13

613

0.21

0.21

String#initialize_copy

 
... a lot of output ...
--------------------------------------------

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.


RAILSBENCH

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.



blog comments powered by Disqus
RUBY-ON-RAILS ARTICLES

- Ruby-on-Rails Faces Second Security Flaw in ...
- Ruby 2.0 Prepped for February 2013 Release
- Why LinkedIn Switched from Ruby on Rails
- Adding Style with Action Pack
- Handling HTML in Templates with Action Pack
- Filters, Controllers and Helpers in Action P...
- Action Pack and Controller Filters
- Action Pack Categories and Events
- Logging Out, Events and Templates with Actio...
- Action Pack Sessions and Architecture
- More on Action Pack Partial Templates
- Action Pack Partial Templates
- Displaying Error Messages with the Action Pa...
- Action Pack Request Parameters
- Creating an Action Pack Registration Form

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials