分析黄瓜测试 (ruby/rails)

发布于 2024-07-30 08:56:55 字数 590 浏览 4 评论 0原文

与 Cucumber 测试相关的探查器/分析相关问题。

我们的一项黄瓜测试运行得相当慢。 我不想猜测我们的应用程序在哪里花费了时间,而是想以编程方式知道。

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

什么不起作用:

  $ 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

这给出了结果,但我不得不猜测这个方法是瓶颈

(我正在使用黄瓜0.3.94, Rails 2.3.2,Ruby 1.8.7(2008-08-11 补丁级别 72)[i686-darwin9.6.0])

Profiler/profiling related issue with Cucumber testing.

One of our cucumber tests run fairly slow. In stead of guessing on where our application is spending time, I'd like to know programatically.

How do I trigger a cucumber test with a profiler???

What did not work:

  $ URL=/projects/by/114951412 #URL to slow rails page
  $ script/performance/profiler 'app.get "$URL"' 50

This does not work because 'app.get' only works in console and not available for profiler script

  $ EXPENSIVE_METHOD="Project.find('6300003243').aggregated_total_amount"
  $ script/performance/profiler "$EXPENSIVE_METHOD" 50

This gives a result but I have to guess that this method is the bottleneck

(I'm using cucumber 0.3.94, rails 2.3.2, ruby 1.8.7 (2008-08-11 patchlevel 72) [i686-darwin9.6.0])

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

岛歌少女 2024-08-06 08:56:55

还可以尝试使用 cucumber --format 来获取有关最慢步骤的一些统计信息。

Also try cucumber --format usage to get some stats about the slowest steps.

无远思近则忧 2024-08-06 08:56:55

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

$ 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行的单个黄瓜场景,但结果不是特别有用

One more experiment is actually an answer to my question but did not give me but does not really give me a particularly useful result

$ 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

This actually runs the single cucumber scenario on line 36, but the result is not particularly useful

ま昔日黯然 2024-08-06 08:56:55

使用 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

Using ruby-prof, you can start the profiler before the subject code and stop it again after. eg.:

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文