我正在嘗試使用fprof獲得更好的性能可視化軟件。但是,默認值是使用掛鐘測量的,但我想用cpu時間來測量它。因此,我在shell上運行以下命令,但出現錯誤。無法真正找到它在互聯網或erlang文檔中失敗的原因。有人有任何提示嗎?在CPU時間使用fprof進行erlang性能分析
% fprof:trace([start, {cpu_time, true}]).
{error,not_supported}
我正在嘗試使用fprof獲得更好的性能可視化軟件。但是,默認值是使用掛鐘測量的,但我想用cpu時間來測量它。因此,我在shell上運行以下命令,但出現錯誤。無法真正找到它在互聯網或erlang文檔中失敗的原因。有人有任何提示嗎?在CPU時間使用fprof進行erlang性能分析
% fprof:trace([start, {cpu_time, true}]).
{error,not_supported}
以下代碼來自文件fprof.erl
,它顯示了錯誤消息的來源。但是我不知道如何繼續找到erlang:trace
的源代碼。它可能由c寫成。如果可以找到trace的源代碼,可以揭開祕密。
trace_on(Procs, Tracer, {V, CT}) ->
case case CT of
cpu_time ->
try erlang:trace(all, true, [cpu_timestamp]) of _ -> ok
catch
error:badarg -> {error, not_supported} %% above error message is shown here
end;
wallclock -> ok
end
of ok ->
MatchSpec = [{'_', [], [{message, {{cp, {caller}}}}]}],
erlang:trace_pattern(on_load, MatchSpec, [local]),
erlang:trace_pattern({'_', '_', '_'}, MatchSpec, [local]),
lists:foreach(
fun (P) ->
erlang:trace(P, true, [{tracer, Tracer} | trace_flags(V)])
end,
Procs),
ok;
Error ->
Error
end.
fprof的CPU_TIME標誌轉換跟蹤的cpu_timestamp在上述代碼段中顯示:
根據http://erlang.org/doc/man/erlang.html#trace-3:
cpu_timestamp
爲二郎節點的全局跟蹤標誌這使得所有跟蹤時間戳都處於CPU時間,而不是掛鐘。只有
PidSpec==all
才允許。如果主機操作系統不支持高分辨率CPU時間測量,則trace/3
將退出badarg
。
因此,如果調用erlang:trace(all, true, [cpu_timestamp])
返回badarg異常,則表示此功能在您的平臺上不受支持。
你是在OSX還是在Windows上? –