在CPU时间中使用fprof进行Erlang性能分析

dog*_*zar 5 erlang profiling

我正在尝试使用fprof对软件进行更好的性能可视化。但是,默认值是使用壁钟测量的,但是我想使用cpu时间来测量它。因此,我在外壳程序上运行以下命令,但出现错误。在Internet或erlang文档中无法真正找到其失败的原因。有人有什么提示吗?

% fprof:trace([start, {cpu_time, true}]).
{error,not_supported}
Run Code Online (Sandbox Code Playgroud)

Che*_* Yu 1

以下代码来自文件fprof.erl,它显示了错误消息的来源。但我不知道如何继续找到erlang:trace. 可能是c写的。如果能找到trace的源代码,秘密就能被揭开。

\n\n
trace_on(Procs, Tracer, {V, CT}) ->\n    case case CT of\n         cpu_time ->\n         try erlang:trace(all, true, [cpu_timestamp]) of _ -> ok\n         catch\n             error:badarg -> {error, not_supported} \xef\xbc\x85\xef\xbc\x85 above error message is shown here\n         end;\n         wallclock -> ok\n     end\n    of ok ->\n        MatchSpec = [{'_', [], [{message, {{cp, {caller}}}}]}],\n        erlang:trace_pattern(on_load, MatchSpec, [local]),\n        erlang:trace_pattern({'_', '_', '_'}, MatchSpec, [local]),\n        lists:foreach(\n          fun (P) ->\n              erlang:trace(P, true, [{tracer, Tracer} | trace_flags(V)])\n          end,\n          Procs),\n        ok;\n    Error ->\n        Error\n    end.\n
Run Code Online (Sandbox Code Playgroud)\n