支援
RVM 由志工社群維護,請將問題回報至 RVM 問題追蹤器。
如果您能提供協助或希望成為維護人員之一 - 只需開始提供協助即可。您可以在 RVM Github 組織 找到更多與 RVM 相關的專案。
贊助商
Carbon Ads

使用 RVM 進行基準測試

如果您有一段程式碼,想一次在多個 Ruby 版本中進行基準測試,現在可以使用 RVM 輕鬆達成。假設

$ cat increment.rb
require 'benchmark'

puts RUBY_DESCRIPTION
puts Benchmark.measure do
  y=0
  1000.times do |x|
    y = x + 1
  end
end

我們可以非常輕鬆地針對多個 Ruby 版本對這段程式碼進行基準測試

$ rvm 1.8.6,1.8.7,1.9.1,ree do ruby increment.rb

ruby-1.8.6-p383: ruby 1.8.6 (2009-08-04 patchlevel 383) [i686-darwin10.0.0]

Rehearsal ---------------------------------------------------------------
benchmarking 'increment.rb'   0.000000   0.000000   0.000000 (  0.000261)
\------------------------------------------------------ total: 0.000000sec

user     system      total        real
benchmarking 'increment.rb'   0.000000   0.000000   0.000000 (  0.000263)

ruby-1.8.7-p174: ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10.0.0]

Rehearsal ---------------------------------------------------------------
benchmarking 'increment.rb'   0.000000   0.000000   0.000000 (  0.001448)
\------------------------------------------------------ total: 0.000000sec

user     system      total        real
benchmarking 'increment.rb'   0.000000   0.000000   0.000000 (  0.001364)

ruby-1.9.1-p243: ruby 1.9.1p243 (2009-07-16 revision 24175) [i386-darwin10.0.0]

Rehearsal ---------------------------------------------------------------
benchmarking 'increment.rb'   0.000000   0.000000   0.000000 (  0.000096)
\------------------------------------------------------ total: 0.000000sec

user     system      total        real
benchmarking 'increment.rb'   0.000000   0.000000   0.000000 (  0.000090)

ruby-enterprise-1.8.6-20090610: ruby 1.8.6 (2008-08-11 patchlevel 287) [i686-darwin10.0.0]
Ruby Enterprise Edition 20090610

Rehearsal ---------------------------------------------------------------
benchmarking 'increment.rb'   0.000000   0.000000   0.000000 (  0.000281)
\------------------------------------------------------ total: 0.000000sec

user     system      total        real
benchmarking 'increment.rb'   0.000000   0.000000   0.000000 (  0.000272)

備註