Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 分析cucumber测试(ruby/rails)_Ruby On Rails_Testing_Profiling_Cucumber_Profiler - Fatal编程技术网

Ruby on rails 分析cucumber测试(ruby/rails)

Ruby on rails 分析cucumber测试(ruby/rails),ruby-on-rails,testing,profiling,cucumber,profiler,Ruby On Rails,Testing,Profiling,Cucumber,Profiler,与黄瓜测试相关的分析器/评测问题 我们的一个黄瓜测试运行得相当慢。我不想猜测我们的应用程序在哪里花费时间,而是想通过编程来了解 如何使用分析器触发黄瓜测试 什么不起作用: $ URL=/projects/by/114951412 #URL to slow rails page $ script/performance/profiler 'app.get "$URL"' 50 这不起作用,因为“app.get”仅在控制台中起作用,不可用于探查器脚本 $ EXPENSIVE_METHO

与黄瓜测试相关的分析器/评测问题

我们的一个黄瓜测试运行得相当慢。我不想猜测我们的应用程序在哪里花费时间,而是想通过编程来了解

如何使用分析器触发黄瓜测试

什么不起作用:

  $ URL=/projects/by/114951412 #URL to slow rails page
  $ script/performance/profiler 'app.get "$URL"' 50
这不起作用,因为“app.get”仅在控制台中起作用,不可用于探查器脚本

  $ EXPENSIVE_METHOD="Project.find('6300003243').aggregated_total_amount"
  $ script/performance/profiler "$EXPENSIVE_METHOD" 50
这给出了一个结果,但我不得不猜测这种方法是瓶颈


(我使用的是cucumber 0.3.94、rails 2.3.2、ruby 1.8.7(2008-08-11 patchlevel 72)[i686-darwin9.6.0])

使用ruby prof,您可以在主题代码之前启动探查器,然后再停止它。例如:

require 'ruby-prof'
RubyProf.start
# code here
result = RubyProf.stop

# You can then output the trace in different ways.
# Simply print a overview to stdout
printer = RubyProf::FlatPrinter.new(result)
printer.print($stdout, :min_percent => 0.1)

# Save a callgrind trace
# You can load this up in kcachegrind or a compatible tool.
printer = RubyProf::CallTreePrinter.new(result)
File.open "callgrind.out.42", 'w' do |file|
  RubyProf::CallTreePrinter.new(result).print(file)
end

还有一个实验实际上是对我的问题的回答,但并没有给我一个特别有用的结果

$ PROJECT_DIR=`pwd`
$ which cucumber
/usr/local/bin/cucumber
$ ln -s `which cucumber` cukes #required for profiler to have local file in next step
$ ruby-prof cukes -- features/manager_overview.feature:36

这实际上在第36行运行了单cumber场景,但结果并不是特别有用

还可以尝试cumber--格式的使用,以获得有关最慢步骤的一些统计信息。

我喜欢您的方法,但不幸的是,它使我有可能只关注我认为可能存在问题的地方。我想要一种更通用的方法,它可能可以与hudsonI这样的CI工具一起运行。我不确定CI服务器上的评测会增加什么价值。您需要一个人来读取分析数据,以便从中获得有用的信息。使用cucumber--format配置文件可以指示哪些场景(和步骤)运行缓慢。我已经知道,这一步是我问题的根本原因,因为有很多费用报告:1.8471970,因为我管理了45个项目,其中1个费用报告为100 DKK#features/manager_overview。feature:37现在,最有趣的部分是我的应用程序中的哪些地方占用了时间!仅供参考,看起来
--格式配置文件
现在已重命名为
--格式用法