简体   繁体   English

使用rails-perftest启用内存报告(Rails 4.1.4,Ruby 2.1.2)

[英]Enable memory reports with rails-perftest (Rails 4.1.4, Ruby 2.1.2)

I am using rails 4.1.4, ruby 2.1.2 and rvm. 我使用rails 4.1.4,ruby 2.1.2和rvm。

Gemfile (extract) Gemfile(提取)

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

I installed ruby using these commands (in order to apply patch which enables memory profiling) 我使用这些命令安装了ruby(为了应用启用内存分析的补丁)

rvm get stable
rvm reinstall 2.1.2 --patch railsexpress

But still no luck and memory reports are empty with rake test:benchmark or rake test:profile 但仍然没有运气和记忆报告是空的rake test:benchmarkrake test:profile

I was trying to get the same Ruby patch and version working with a Rails 3 benchmark and that was broken too, albeit in a different way. 我试图获得相同的Ruby补丁和版本使用Rails 3基准测试,虽然以不同的方式也被打破了。 It looks to me like this is an oversight in Rails. 在我看来,这是对Rails的疏忽。 I'm seeing this warning string on a Rails 3.2 app 我在Rails 3.2应用程序上看到这个警告字符串

$ 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 seems to be that ActiveSupport 3.2 isn't aware of Ruby versions higher that 2.0 for this particular piece of code 问题似乎是ActiveSupport 3.2并不知道这个特定代码的Ruby版本高于2.0

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 请参阅https://www.omniref.com/ruby/gems/activesupport/3.2.12/symbols/ActiveSupport::Testing::Performance::Metrics::CpuTime#line=145

After editing the version check manually I can confirm that the patch does work in Rails 3 with version 2.1.2. 手动编辑版本检查后,我可以确认该补丁在版本2.1.2的Rails 3中有效。 Perhaps you could check your RUBY_VERSION and RUBY_ENGINE constants for anything unusual? 也许你可以检查你的RUBY_VERSION和RUBY_ENGINE常量是否有异常?

(I understand this isn't really an answer but I don't have enough reputation to comment. Also it hopefully rules out the rvm patch and ruby-prof as a problem) (我知道这不是一个真正的答案,但我没有足够的声誉来评论。还希望排除rvm补丁和ruby-prof作为问题)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM