【发布时间】:2011-07-19 00:03:48
【问题描述】:
我在我的一个程序上运行了 ruby-profiler。我试图弄清楚每个字段的含义。我猜一切都是 CPU 时间(而不是挂钟时间),这太棒了。我想了解“---”代表什么。那里是否有某种堆栈信息。调用 a/b 是什么意思?
Thread ID: 81980260
Total Time: 0.28
%total %self total self wait child calls Name
--------------------------------------------------------------------------------
0.28 0.00 0.00 0.28 5/6 FrameParser#receive_data
100.00% 0.00% 0.28 0.00 0.00 0.28 6 FrameParser#read_frames
0.28 0.00 0.00 0.28 4/4 ChatServerClient#receive_frame
0.00 0.00 0.00 0.00 5/47 Fixnum#+
0.00 0.00 0.00 0.00 1/2 DebugServer#receive_frame
0.00 0.00 0.00 0.00 10/29 String#[]
0.00 0.00 0.00 0.00 10/21 <Class::Range>#allocate
0.00 0.00 0.00 0.00 10/71 String#index
--------------------------------------------------------------------------------
100.00% 0.00% 0.28 0.00 0.00 0.28 5 FrameParser#receive_data
0.28 0.00 0.00 0.28 5/6 FrameParser#read_frames
0.00 0.00 0.00 0.00 5/16 ActiveSupport::CoreExtensions::String::OutputSafety#add_with_safety
--------------------------------------------------------------------------------
0.28 0.00 0.00 0.28 4/4 FrameParser#read_frames
100.00% 0.00% 0.28 0.00 0.00 0.28 4 ChatServerClient#receive_frame
0.28 0.00 0.00 0.28 4/6 <Class::Lal>#safe_call
--------------------------------------------------------------------------------
0.00 0.00 0.00 0.00 1/6 <Class::Lal>#safe_call
0.00 0.00 0.00 0.00 1/6 DebugServer#receive_frame
0.28 0.00 0.00 0.28 4/6 ChatServerClient#receive_frame
100.00% 0.00% 0.28 0.00 0.00 0.28 6 <Class::Lal>#safe_call
0.21 0.00 0.00 0.21 2/4 ChatUserFunction#register
0.06 0.00 0.00 0.06 2/2 ChatUserFunction#packet
0.01 0.00 0.00 0.01 4/130 Class#new
0.00 0.00 0.00 0.00 1/1 DebugServer#profile_stop
0.00 0.00 0.00 0.00 1/33 String#==
0.00 0.00 0.00 0.00 1/6 <Class::Lal>#safe_call
0.00 0.00 0.00 0.00 5/5 JSON#parse
0.00 0.00 0.00 0.00 5/8 <Class::Log>#log
0.00 0.00 0.00 0.00 5/5 String#strip!
--------------------------------------------------------------------------------
【问题讨论】:
-
我想指出的是,如果你在调试器下运行,手动中断它,并显示调用堆栈,4 次,平均 3 个样本将是这样的:
read_frames -> receive_frame -> safe_call -> register -> ...所以你的瓶颈会向你呼喊以引起注意。那是this method。剩下的 25% 的时间大部分是... -> packet -> ...。其他一切基本上都无关紧要。 -
@Mike,如果您传达了您如何解释图表以得出该结论,那将会很有帮助,因为我认为这就是这个问题试图解决的问题(如何解释这个输出)。对我有用!
-
@Charles:我正在查看“总计”列,这是在堆栈上花费的时间。第一行大约是
read_frames。它所有的时间都花在打电话给receive_frame。第三行是关于receive_frame,它的所有时间都在safe_call。第四组说safe_call大部分时间花在register,然后是packet,还有一点点在new。 (第二组说receive_data总是在顶部。)