This module is used to profile a program to find out how the execution time is used.
In R7 the eprof
module uses the new local call trace feature,
meaning that you no longer need to specially compile any of the modules.
Eprof will automatically turn on local trace for all loaded modules
(any for any that are loaded when during a profile session).
When profiling is stopped, Eprof will disable local call trace for
all functions in all loaded modules.
The R7 version is faster than previous versions. But you can still expect significant slowdowns, in most cases at least 100 percent.
start() -> {ok, Pid} | {error, {already_started, Pid}}
profile(Rootset, Mod, Fun, Args)
This function evaluates the expression spawn(Mod, Fun, Args)
and profiles the process which evaluates it. The profiling is done for one function with a set of arguments in a certain root set of processes. All processes which are created by that function are profiled, together with its root set and all processes which are created by processes in that root set.
The profiling is terminated when the given function returns a value. The application must ensure that the function is truly synchronized and that no work continues after the function has returned a value.
The root set is a list of Pids or atoms. If atoms, they are assumed to be registered processes.
profile(Rootset) -> profiling | error
Sometimes, it is not possible to start profiling with the help of a single function.
For example, if some external stimuli enters the
Erlang runtime system through a port, and the handling of this stimuli
is to be profiled until a response goes out through a port, it
may be appropriate to change the source code and insert
an explicit call to this function. The profile(Rootset)
function
starts the profiling for processes included in Rootset
.
stop_profiling() -> profiling_stopped | profiling_already_stopped
This function stops the collection of statistics performed by the
eprof
process. The eprof
process then holds data which
can be analysed at a later stage.
When the profiling has ended - profiling using profile/4
, or profile/1
together with stop_profiling/0
- the eprof
process can print the data collected during the
run. The printed profiling statistics show the activity for each process.
With this function, the total results of profiling is printed irrespective which process each function has used.
This function ensures that a copy of all printouts are sent to
both File
and the screen.
The actual supervision of execution times is in itself a
CPU intensive activity. A message is sent to the eprof
process
for every function call that is made by the profiled code.
compile(3)