簡體   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)

我使用rails 4.1.4,ruby 2.1.2和rvm。

Gemfile(提取)

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

我使用這些命令安裝了ruby(為了應用啟用內存分析的補丁)

rvm get stable
rvm reinstall 2.1.2 --patch railsexpress

但仍然沒有運氣和記憶報告是空的rake test:benchmarkrake test:profile

我試圖獲得相同的Ruby補丁和版本使用Rails 3基准測試,雖然以不同的方式也被打破了。 在我看來,這是對Rails的疏忽。 我在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

問題似乎是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

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

手動編輯版本檢查后,我可以確認該補丁在版本2.1.2的Rails 3中有效。 也許你可以檢查你的RUBY_VERSION和RUBY_ENGINE常量是否有異常?

(我知道這不是一個真正的答案,但我沒有足夠的聲譽來評論。還希望排除rvm補丁和ruby-prof作為問題)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM