I'm creating a Rails Performance test, as described in the Rails Guide, and I'm having problems with ruby-prof.
I'm using Ruby 1.9.2-p0 (though experienced the same issue on p320) and Rails 3.1.0.
I have a pretty simple test for a controller that is equivalent to this example.
According to the guide, I need to install ruby-prof before I can use performance tests. Sure enough, if I run my performance test without it, I get:
Specify ruby-prof as application's dependency in Gemfile to run benchmarks.
If I follow the guide's instructions to the letter, I add this to my Gemfile:
gem 'ruby-prof', :git => 'git://github.com/wycats/ruby-prof.git'
...and get version 0.11.0 from the wycats repository. When I run my test I get this error:
/Users/craig/.rvm/gems/ruby-1.9.2-p0/bundler/gems/ruby-prof-ffae61a89553/lib/ruby-prof/abstract_printer.rb:44:in `inspect': undefined method `to_s' for #<Class:0x000001025a3f18> (NoMethodError)
from /Users/craig/.rvm/gems/ruby-1.9.2-p0/bundler/gems/ruby-prof-ffae61a89553/lib/ruby-prof/abstract_printer.rb:44:in `full_name'
...
But "wycats" doesn't appear to be the canonical Github repo for ruby-prof. The documentation refers to rdp (Roger Pack). If I use that repo instead:
gem 'ruby-prof', :git => 'git://github.com/rdp/ruby-prof.git'
...I get version 0.11.2, and get this error:
/Users/craig/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.1.0/lib/active_support/testing/performance/ruby.rb:39:in
run': undefined method
values' for [#]:Array (NoMethodError) from /Users/craig/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.1.0/lib/active_support/testing/performance.rb:140:in `run_profile' ...
I get the same error if I just use the gem from rubygems directly (again, version 0.11.2):
gem 'ruby-prof'
Any ideas what's going wrong, or how to resolve it?
It must be said that most of the time, developers claim that Ruby on Rails is slow because of the initially incorrect project architecture, data caching or database optimization. Rails is FAST in terms of the project development speed. That is the main advantage of Ruby on Rails.
To use latest ruby-prof version you need rails 3.2.3, I don't know what ruby-prof version you can use with rails 3.1, maybe you can copy lib/active_support/testing/performance/ruby.rb from activesupport 3.2.3
The problem is in activesupport-3.2.2\lib\active_support\testing\performance\ruby.rb.
Change line 39 from:
@total = @data.threads.sum(0) { |method_infos| method_infos.max.total_time }
To:
@total = @data.threads.sum(0) {|thread| thread.top_method.total_time}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With