File: eprof.3

package info (click to toggle)
erlang-manpages 1%3A12.b.3-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 4,188 kB
  • ctags: 2
  • sloc: makefile: 68; perl: 30; sh: 15
file content (136 lines) | stat: -rw-r--r-- 3,570 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
.TH eprof 3 "tools  2.6.1" "Ericsson AB" "ERLANG MODULE DEFINITION"
.SH MODULE
eprof \- A Time Profiling Tool for Erlang
.SH DESCRIPTION
.LP
The module \fIeprof\fR 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 specfied set of processes is enabled when profiling is begun, and disabled when profiling is stopped\&.
.LP
When using Eprof, expect a significant slowdown in program execution, in most cases at least 100 percent\&.

.SH EXPORTS
.LP
.B
start() -> {ok,Pid} | {error,Reason}
.br
.RS
.TP
Types
Pid = pid()
.br
Reason = {already_started, Pid}
.br
.RE
.RS
.LP
Starts the Eprof server which owns the Eprof internal database\&.
.RE
.LP
.B
start_profiling(Rootset) -> profiling | error
.br
.B
profile(Rootset) -> profiling | error
.br
.RS
.TP
Types
Rootset = [atom() | pid()]
.br
.RE
.RS
.LP
Starts profiling for the processes in \fIRootset\fR (and any new processes spawned from them)\&. Information about activity in any profiled process is stored in the Eprof database\&.
.LP
\fIRootset\fR is a list of pids and registered names\&.
.LP
The function returns \fIprofiling\fR if tracing could be enabled for all processes in \fIRootset\fR, or \fIerror\fR otherwise\&.
.RE
.LP
.B
stop_profiling() -> profiling_stopped | profiling_already_stopped
.br
.RS
.LP
Stops profiling started with \fIstart_profiling/1\fR or \fIprofile/1\fR\&.
.RE
.LP
.B
profile(Rootset,Fun) -> {ok,Value} | {error,Reason} | error
.br
.B
profile(Rootset,Module,Function,Args) -> {ok,Value} | {error,Reason} | error
.br
.RS
.TP
Types
Rootset = [atom() | pid()]
.br
Fun = fun() -> term()
.br
Module = Function = atom()
.br
Args = [term()]
.br
Value = Reason = term()
.br
.RE
.RS
.LP
This function first spawns a process \fIP\fR which evaluates \fIFun()\fR or \fIapply(Module, Function, Args)\fR\&. Then, it starts profiling for \fIP\fR and the processes in \fIRootset\fR (and any new processes spawned from them)\&. Information about activity in any profiled process is stored in the Eprof database\&.
.LP
\fIRootset\fR is a list of pids and registered names\&.
.LP
If tracing could be enabled for \fIP\fR and all processes in \fIRootset\fR, the function returns \fI{ok, Value}\fR when \fIFun()\fR/\fIapply\fR returns with the value \fIValue\fR, or \fI{error, Reason}\fR if \fIFun()\fR/\fIapply\fR fails with exit reason \fIReason\fR\&. Otherwise it returns \fIerror\fR immediately\&.
.LP
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\&.
.RE
.LP
.B
analyse()
.br
.RS
.LP
Call this function when profiling has been stopped to display the results per process, that is:
.RS 2
.TP 2
*
how much time has been used by each process, and
.TP 2
*
in which function calls this time has been spent\&.
.RE
.LP
Time is shown as percentage of total time, not as absolute time\&.
.RE
.LP
.B
total_analyse()
.br
.RS
.LP
Call this function when profiling has been stopped to display the results per function call, that is in which function calls the time has been spent\&.
.LP
Time is shown as percentage of total time, not as absolute time\&.
.RE
.LP
.B
log(File) -> ok
.br
.RS
.TP
Types
File = atom() | string()
.br
.RE
.RS
.LP
This function ensures that the results displayed by \fIanalyse/0\fR and \fItotal_analyse/0\fR are printed both to the file \fIFile\fR and the screen\&.
.RE
.LP
.B
stop() -> stopped
.br
.RS
.LP
Stops the Eprof server\&.
.RE