Enable memory reporting with rails-perftest (Rails 4.1.4, Ruby 2.1.2)

I am using rails 4.1.4, ruby ​​2.1.2 and rvm.

Gemfile (extract)

gem 'rails-perftest'
gem 'ruby-prof', group: :test

      

I installed ruby ​​using these commands (in order to apply a patch that allows memory profiling)

rvm get stable
rvm reinstall 2.1.2 --patch railsexpress

      

But still fails and the memory reports are empty with rake test:benchmark

orrake test:profile

+3


source to share


1 answer


I tried to get the same patch and Ruby version as Rails 3 and that broke too, albeit in a different way. It seems to me that this is an oversight in Rails. I see this warning line in Rails 3.2 application

$ bundle exec rake test:benchmark
Update your ruby interpreter to be able to run benchmarks.
$ bundle exec rails -v
Rails 3.2.21

      

The problem is ActiveSupport 3.2 doesn't know about Ruby versions higher than 2.0 for this particular piece of code

if RUBY_VERSION.between?('1.9.2', '2.0')
  require 'active_support/testing/performance/ruby/yarv'
elsif RUBY_VERSION.between?('1.8.6', '1.9')
  require 'active_support/testing/performance/ruby/mri'
else
  $stderr.puts 'Update your ruby interpreter to be able to run benchmarks.'
  exit
end

      



see https://www.omniref.com/ruby/gems/activesupport/3.2.12/symbols/ActiveSupport::Testing::Performance::Metrics::CpuTime#line=145

After manually editing the version check, I can confirm that the patch works in Rails 3 with version 2.1.2. Perhaps you could check your RUBY_VERSION and RUBY_ENGINE constants for something unusual?

(I realize this isn't actually an answer, but I don't have enough reputation to comment. Also it hopefully rules out rvm and ruby-prof fixing as a problem)

+1


source







All Articles