开发者

Finding out which higher level function is making lots of low level calls

I have a function that is being called more than a thousand times, slowing everything down. However, it is a low level function, and do not know whic开发者_如何学Ch of my high level function is lopping and making these calls. How can i find out?


If the low-level function is written in Ruby, reopen its class and use alias_method_chain:

class TheClass
  def low_level_with_debug_output
    puts "I am being called by #{caller.first.inspect}"
    low_level_without_debug_output
  end

  alias_method_chain :low_level, :debug_output
end

alias_method_chain is a Rails-ism.

If the low-level function is not written in Ruby, you may need to instead use ruby-debug or even gdb on the interpreter itself to get at the stack trace.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜