2011-10-03 25 views
4

我要爲我的Rails 3應用程序做了性能測試,我就照導軌在線指南沒有預期輸出爲我的性能測試

rake test:profile 

一個嘗試,它給了一些輸出爲:

Specify ruby-prof as application's dependency in Gemfile to run benchmarks. 
Loaded suite /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/rake_test_loader 
Started 
. 
Finished in 0.326233 seconds. 

1 tests, 0 assertions, 0 failures, 0 errors, 0 skips 

但根據指南,應該是這樣的:

BrowsingTest#test_homepage (31 ms warmup) 
      wall_time: 6 ms 
       memory: 437.27 KB 
      objects: 5,514 
      gc_runs: 0 
      gc_time: 19 ms 

,還有一些日誌文件機生產線在應用程序的tmp/performance目錄中,這在我的情況中不存在。

性能測試是生成的樣本測試,browsing_test.rb,在我的應用程序的測試\性能DIR:

require 'test_helper' 
require 'rails/performance_test_help' 

# Profiling results for each test method are written to tmp/performance. 
class BrowsingTest < ActionDispatch::PerformanceTest 
    def test_homepage 
    get '/' 
    end 
end 

我的軌道版本是3.0.10。任何人都可以給我一些提示或提示嗎?

回答

10

有完全相同的問題,並通過運行解決它

rvm install 1.9.2-p290 --patch gcdata # Make sure you have the same patch version 

(注:不知道多少那一步,因爲我有一個錯誤幫助,但因爲是我所做的一部分...)

添加到我的Gemfile

gem 'ruby-prof', :git => 'git://github.com/wycats/ruby-prof.git' 
gem 'test-unit' 

當然和運行

bundle install 

一些閱讀,幫助我

+0

嘿,你的解決方案適用於我的問題!非常感謝你!順便說一句,我沒有添加pacth,只安裝了兩個gem,儘管我不知道爲什麼我必須安裝'test-unit'來使'ruby-prof'正常工作。 – Robert

+0

很高興我可以幫助:)。現在我在guides.rubyonrails.org中提到了基準助手方法的另一個問題。他們不會在我的日誌中輸出任何內容... – Nycen