在分析 ruby 应用程序时是否可以忽略不相关的方法?
在使用 ruby-prof 时,以 graph-html 模式打印,一种方法的报告显示(带有一些截图)
%Total %Self Total Self Wait Child Calls Name Line
52.85% 0.00% 51.22 0.00 0.00 51.22 1 ClassName#method_name 42
51.22 0.00 0.00 51.22 1/3 Hash#each 4200
显然,不是 Hash#each
花费了很长时间,而是 Hash#each 中的yield
块。
查看 Hash#each 的报告会令人困惑,因为它报告了使用 Hash#each 的任何内容所调用的所有代码。
是否可以要求 ruby-prof 将生成的代码的信息放入 ClassName#method_name 的报告中?
使用 min_percent
或切换到平面配置文件似乎没有帮助。
While using ruby-prof, printed out in graph-html mode, the report for one method says (with some snipping)
%Total %Self Total Self Wait Child Calls Name Line
52.85% 0.00% 51.22 0.00 0.00 51.22 1 ClassName#method_name 42
51.22 0.00 0.00 51.22 1/3 Hash#each 4200
Obviously, it's not Hash#each
that's taking a long time, but the yield
block within Hash#each.
Looking at the report for Hash#each is confusing because it reports on all of the code called by anything that uses Hash#each.
Is it possible to ask ruby-prof to put the information on yielded code in ClassName#method_name
's report?
Using min_percent
or switching to a flat profile doesn't seem to help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
ruby-prof 0.9.0 版本允许方法消除。例如,要消除
Integer#times
,使用so
将直接指示
method_a
和method_b
之间的关系。Version 0.9.0 of ruby-prof allows method elimination. For example, to eliminate
Integer#times
, useso that
will indicate the relationship between
method_a
andmethod_b
directly.如果您不介意低技术含量,也许您需要考虑这个。您所需要的只是能够暂停调试器。保证,它会快速找到您可以通过其他方式找到的任何内容,并且不会向您显示任何不相关的代码。
If you don't mind low-tech, maybe you want to consider this. All you need is to be able to pause the debugger. Guaranteed, it will quickly find anything you can find any other way, and not show you any irrelevant code.