2

到目前为止,我发现的最佳匹配是从命令行使用 ruby​​-prof 并尝试猜测从那里读取的图形。

require 'ruby-prof'

# Profile the code
RubyProf.start
...
[code to profile]
...
result = RubyProf.stop

# Print a flat profile to text
printer = RubyProf::FlatPrinter.new(result)
printer.print(STDOUT)

https://github.com/rdp/ruby-prof

这种方法的主要问题是你必须修改你的代码才能看到分析并且不是很可读。

我也尝试过一些 IDE:RubyMine、Aptana 和 Netbeans,但没有人有适当的图形界面来分析代码。

有什么推荐吗?

4

2 回答 2

3

试试 ruby​​-prof 命令行工具: http ://ruby-prof.rubyforge.org/files/bin/ruby-prof.html

并使用以下内容:

ruby-prof -p graph_html -f filename.html rubycode.rb
于 2012-01-24T12:11:03.983 回答
1

结帐迷你分析器:http ://railscasts.com/episodes/368-miniprofiler

文档可以在这里找到:https ://github.com/SamSaffron/MiniProfiler/tree/master/Ruby

结帐特殊参数:pp=flamegraph- 分析起来非常容易。对于 ruby​​ 2.0,它甚至可以在生产环境中使用!

于 2013-07-02T15:38:22.723 回答