我正在创建一个Rails性能测试,正如在导轨中所描述的那样,而且我在ruby上遇到了问题。
我使用的是Ruby1.9.2-P0(尽管在p320上遇到了同样的问题)和Rails 3.1.0。
对于一个相当于这个例子的控制器,我有一个非常简单的测试。
根据导游,在使用性能测试之前,我需要安装ruby。当然,如果我在没有测试的情况下运行我的性能测试,我得到:
指定ruby-prof作为Gemfile中应用程序的依赖项来运行基准测试。
如果我按照导游的指示写信,我就把它添加到我的Gemfile中:
宝石'ruby-prof',:git =>‘git://github.com/wycat/ruby-prof.git’
...and从wycats存储库获得0.11.0版。当我运行测试时,我会得到以下错误:
/Users/craig/.rvm/gems/ruby-1.9.2-p0/bundler/gems/ruby-prof-ffae61a89553/lib/ruby-prof/abstract_printer.rb:44:in `inspect': undefined method `to_s' for #<Class:0x000001025a3f18> (NoMethodError)
from /Users/craig/.rvm/gems/ruby-1.9.2-p0/bundler/gems/ruby-prof-ffae61a89553/lib/ruby-prof/abstract_printer.rb:44:in `full_name'
...但是,“猫科动物”似乎并不是红宝石教授的典型的Github回购。文档引用rdp (Roger )。如果我用那个回购:
宝石'ruby-prof',:git => 'git://github.com/rdp/ruby-prof.git‘
...I获得0.11.2版本,并获得以下错误:
/Users/craig/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.1.0/lib/active_support/testing/performance/ruby.rb:39:in
run': undefined method值为#:数组(NoMethodError)从/Users/craig/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.1.0/lib/active_support/testing/performance.rb:140:in `run_profile.
如果我直接使用来自rubygems的宝石(同样,0.11.2版),我会得到同样的错误:
宝石‘红宝石教授’
有什么不对劲的地方吗?或者如何解决?
发布于 2012-06-01 01:12:26
要使用最新的ruby版本,您需要rails 3.2.3,我不知道您可以在rails 3.1中使用哪个ruby版本,也许您可以从activesupport3.2.3复制lib/active_support/testing/performance/ruby.rb
发布于 2012-06-03 06:47:09
问题在activesupport-3.2.2\lib\active_support\testing\performance\ruby.rb.中
将第39行改为:
@total = @data.threads.sum(0) { |method_infos| method_infos.max.total_time }至:
@total = @data.threads.sum(0) {|thread| thread.top_method.total_time}发布于 2012-06-22 15:42:44
Rails 3.2.6已经纠正了这一点。支持/测试/性能/ruby.rb
第39行
@total = @data.threads.sum(0) { |thread| thread.methods.max.total_time }在Rails 3.2.3中
它是:
@total = @data.threads.values.sum(0) { |method_infos| method_infos.max.total_time }看起来值方法在这里失败了。
https://stackoverflow.com/questions/10779121
复制相似问题