我在我的一個程序上運行了ruby-profiler。我試圖弄清楚每個字段的含義。我猜一切都是CPU時間(而不是掛鐘時間),這太棒了。我想了解「---」代表什麼。那裏有一些堆棧信息。呼叫a/b是什麼意思?瞭解ruby-prof輸出
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 - >註冊 - > ...'所以你的瓶頸將是呼籲你注意。這是[此方法](http://stackoverflow.com/questions/375913/what-can-i-use-to-profile-c-code-in-linux/378024#378024)。剩下的25%的時間大部分是...... - >包 - > ...。其他一切基本上是不相關的。 – 2011-03-20 16:49:40
@Mike,如果你傳達了你如何解釋圖表來得出結論,這將是有益的,因爲我認爲這就是這個問題試圖解決的問題(如何解釋這個輸出)。這對我有用! – 2014-03-19 00:22:16
@Charles:我正在查看「總計」列,這是花費在堆棧上的時間。第一組線是關於'read_frames'的。它所有的時間都花在調用'receive_frame'上。第三組線是關於'receive_frame',它將所有時間花費在'safe_call'中。第四類說'safe_call'大部分時間都花在'register'中,然後是'packet',並且在'new'中花了一點時間。 (第二組表示'receive_data'始終位於頂部。) – 2014-03-19 12:37:13