table of contents
other versions
- jessie 1:17.3-dfsg-4+deb8u2
- jessie-backports 1:19.2.1+dfsg-2+deb9u1~bpo8+1
- stretch 1:19.2.1+dfsg-2+deb9u2
- testing 1:21.2.5+dfsg-1
- unstable 1:21.2.6+dfsg-1
- experimental 1:22.0~rc1+dfsg-1
eprof(3erl) | Erlang Module Definition | eprof(3erl) |
NAME¶
eprof - A Time Profiling Tool for ErlangDESCRIPTION¶
The module eprof provides a set of functions for time profiling of Erlang programs to find out how the execution time is used. The profiling is done using the Erlang trace BIFs. Tracing of local function calls for a specified set of processes is enabled when profiling is begun, and disabled when profiling is stopped. When using Eprof expect a slowdown in program execution.EXPORTS¶
start() -> {ok,Pid} | {error,Reason}
Types:
Pid = pid()
Reason = {already_started,Pid}
Starts the Eprof server which holds the internal state of the collected
data.
start_profiling(Rootset) -> profiling | {error, Reason}
Types:
Rootset = [atom() | pid()]
Pattern = {Module, Function, Arity}
Module = Function = atom()
Arity = integer()
Options = [set_on_spawn]
Reason = term()
Starts profiling for the processes in Rootset (and any new processes
spawned from them). Information about activity in any profiled process is
stored in the Eprof database.
Rootset is a list of pids and registered names.
The function returns profiling if tracing could be enabled for all
processes in Rootset, or error otherwise.
A pattern can be selected to narrow the profiling. For instance a specific
module can be selected, and only the code executed in that module will be
profiled.
The set_on_spawn option will active call time tracing for all processes
spawned by processes in the rootset. This is the default behaviour.
stop_profiling() -> profiling_stopped | profiling_already_stopped
Stops profiling started with start_profiling/1 or profile/1.
profile(Fun) -> profiling | {error, Reason}
Types:
Rootset = [atom() | pid()]
Fun = fun() -> term() end
Pattern = {Module, Function, Arity}
Module = Function = atom()
Args = [term()]
Arity = integer()
Options = [set_on_spawn]
Value = Reason = term()
This function first spawns a process P which evaluates Fun() or
apply(Module,Function,Args). Then, it starts profiling for P and
the processes in Rootset (and any new processes spawned from them).
Information about activity in any profiled process is stored in the Eprof
database.
Rootset is a list of pids and registered names.
If tracing could be enabled for P and all processes in Rootset,
the function returns {ok,Value} when Fun()/apply returns
with the value Value, or {error,Reason} if
Fun()/apply fails with exit reason Reason. Otherwise it
returns {error, Reason} immediately.
The set_on_spawn option will active call time tracing for all processes
spawned by processes in the rootset. This is the default behaviour.
The programmer must ensure that the function given as argument is truly
synchronous and that no work continues after the function has returned a
value.
analyze() -> ok
Types:
Type = procs | total
Options = [{filter, Filter} | {sort, Sort}
Filter = [{calls, integer()} | {time, float()}]
Sort = time | calls | mfa
Call this function when profiling has been stopped to display the results per
process, that is:
Call analyze with total option when profiling has been stopped to
display the results per function call, that is in which function calls the
time has been spent.
Time is shown as percentage of total time and as absolute time.
log(File) -> ok
- *
- how much time has been used by each process, and
- *
- in which function calls this time has been spent.
Types:
File = atom() | string()
This function ensures that the results displayed by analyze/0,1,2 are
printed both to the file File and the screen.
stop() -> stopped
Stops the Eprof server.
tools 2.7 | Ericsson AB |