Thursday, January 25, 2007

[PLUGIN RELEASE] - Browser Profiler


===================================
http://rubyforge.org/projects/browser-prof/
===================================


BrowserProfiler a quick way to do performance testing from within your application. While it's often easy to write automated tests that are wrapped with performance profiling, the test implementation of some of rails is totally different in test mode. Also, you might only do certain things in production mode (like caching!) so performance testing in production is really nice.

Simple usage: http://localhost:3000/some/action?browser_profile!

If you add the browser_profile! param to any URL, it will append the profiling output to the bottom of the html file.

What profiling you ask? Well, it needs ruby-prof, which is an awesome library here: http://ruby-prof.rubyforge.org/

We used the ruby convention of bang (!) parameter to imply its modifies itself, the html body.
Walk through your own app while profiling to find issues locally, or even after deployment to your production machines. Dont leave this stuff on in real production, obviously. :)

Advanced Usage:
Often in Rails on post operations, you redirect afterwards. So how do you see the profiling output of a post-redirect operation?

http://localhost:3000/some/post_redirect?file_profile!

Add the file_profile!, and it will output the results to file specified in RAILS_ROOT/log/profile_out.html .

Hint: If you are testing against a site you've deployed somewhere, use FireBug to modify the DOM before the post or Tamper Data to add to the post parameters, and you can add params at will.

The functionality appears to work fine in Rails 1.1, and 1.2, but the tests fail.. Needs more investigation.

License: Released under the MIT license.

Dependencies: ruby-prof (Last tested with ruby-prof 0.4.1)
> gem install ruby-prof

9 comments:

Anonymous said...

This plugin seems really nice, I will testing it ASAP. Thanks, and welcome to RubyCorner!

bassnode said...

Feb 15 13:01:36 ed-laptop rails[17533]: You have a nil object when you didn't expect it!You might have expected an instance of Array.The error occurred while evaluating nil.empty?
/var/www/rails/appA/config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:376:in `new_constants_in'
/var/www/rails/appA/config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:202:in `load_file'
/var/www/rails/appA/config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:94:in `require_or_load'
/var/www/rails/appA/config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:248:in `load_missing_constant'
/var/www/rails/appA/config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:452:in `const_missing'
/var/www/rails/appA/config/../vendor/plugins/browser-prof/lib/browser_profiler.rb:11:in `process'
/var/www/rails/appA/config/../vendor/rails/actionpack/lib/action_controller/base.rb:330:in `process'
/var/www/rails/appA/config/../vendor/rails/railties/lib/dispatcher.rb:41:in `dispatch'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/rails.rb:78:in `process'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/rails.rb:76:in `process'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:618:in `process_client'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:617:in `process_client'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:736:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:736:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:720:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/configurator.rb:271:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/configurator.rb:270:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/bin/mongrel_rails:127:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/command.rb:211:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/bin/mongrel_rails:243
/usr/bin/mongrel_rails:16

Aaron Batalion said...

Ed, What version of rails have you frozen to your vendor dir? AFAIK, this has been tested with 1.1.LATEST, and 1.2, but not edge.

Abhilash V said...

How to change the core Rails validation error messages using plugins?
Or do u know any site that give me answer in brief ?
Pls reply me…

Kanaye said...
This comment has been removed by the author.
Kanaye said...
This comment has been removed by the author.
Kanaye said...

I think i finally figured it out

in your respective environment file,
set
config.cache_classes = true
when this is false you get the reported error.

Ron

John Nagro said...

maybe i've missed something, but i cant seem to find the files? the rubyforge.org project has no files, and the rails plugin script can't find your plugin (even after a discover), could you please point me in the right direction?

thanks!

Val Aleksenko said...

John: You could use script/plugin install svn://viewvc.rubyforge.org/var/svn/browser-prof/trunk. Anyway, I released the plugin in ZIP/TGZ on the project home. Enjoy! ;-)