Erlang performance profiling using fprof in CPU time

I am trying to improve the visualization of my program with fprof. However, the default value is measured using a wall clock, but I want to measure it with the processor time. Therefore, I run the following command in the shell, but I get an error message. Could not find the reason why it is not working on the Internet or in the erlang documentation. Does anyone have any clues?

% fprof:trace([start, {cpu_time, true}]). {error,not_supported} 
+4
source share
2 answers
Flag

fprof cpu_time translates to the cpu_timestamp trace, as shown in the code snippet above:

According to http://erlang.org/doc/man/erlang.html#trace-3 :

cpu_timestamp

The global trace flag for Erlang node, which makes all the timestamps of the trace during the processor, and not on the wall. Allowed only with PidSpec==all . If the host operating system does not support high resolution CPU time measurements, trace/3 exits with badarg .

So, if calling erlang:trace(all, true, [cpu_timestamp]) returns a badarg exception, this means that this function is not supported on your platform.

+1
source

The following code is from the fprof.erl file. It shows where the error message is coming from. But I do not know how to continue searching for the source code of erlang:trace . It can be written c. If the source code for the trace can be found, a secret can be provided.

 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. 
0
source

All Articles