13
13
compliance with the License. You should have received a copy of the
14
14
Erlang Public License along with this software. If not, it can be
15
15
retrieved online at http://www.erlang.org/.
17
17
Software distributed under the License is distributed on an "AS IS"
18
18
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
19
19
the License for the specific language governing rights and limitations
24
24
<title>eprof</title>
35
35
used. The profiling is done using the Erlang trace BIFs. Tracing of
36
36
local function calls for a specified set of processes is enabled when
37
37
profiling is begun, and disabled when profiling is stopped.</p>
38
<p>When using Eprof, expect a significant slowdown in program execution,
39
in most cases at least 100 percent.</p>
38
<p>When using Eprof expect a slowdown in program execution.</p>
47
46
<v>Reason = {already_started,Pid}</v>
50
<p>Starts the Eprof server which owns the Eprof internal database.</p>
49
<p>Starts the Eprof server which holds the internal state of the collected data.</p>
54
<name>start_profiling(Rootset) -> profiling | error</name>
55
<name>profile(Rootset) -> profiling | error</name>
53
<name>start_profiling(Rootset) -> profiling | {error, Reason}</name>
54
<name>start_profiling(Rootset,Pattern) -> profiling | {error, Reason}</name>
56
55
<fsummary>Start profiling.</fsummary>
58
57
<v>Rootset = [atom() | pid()]</v>
58
<v>Pattern = {Module, Function, Arity}</v>
59
<v>Module = Function = atom()</v>
60
<v>Arity = integer()</v>
61
<v>Reason = term()</v>
61
64
<p>Starts profiling for the processes in <c>Rootset</c> (and any new
64
67
<p><c>Rootset</c> is a list of pids and registered names.</p>
65
68
<p>The function returns <c>profiling</c> if tracing could be enabled
66
69
for all processes in <c>Rootset</c>, or <c>error</c> otherwise.</p>
70
<p>A pattern can be selected to narrow the profiling. For instance ca a specific
71
module be selected and only the code processes executes in that module will be
78
<name>profile(Rootset,Fun) -> {ok,Value} | {error,Reason} | error</name>
79
<name>profile(Rootset,Module,Function,Args) -> {ok,Value} | {error,Reason} | error</name>
84
<name>profile(Fun) -> profiling | {error, Reason}</name>
85
<name>profile(Rootset) -> profiling | {error, Reason}</name>
86
<name>profile(Rootset,Fun) -> {ok, Value} | {error,Reason}</name>
87
<name>profile(Rootset,Fun,Pattern) -> {ok, Value} | {error, Reason}</name>
88
<name>profile(Rootset,Module,Function,Args) -> {ok, Value} | {error, Reason}</name>
89
<name>profile(Rootset,Module,Function,Args,Pattern) -> {ok, Value} | {error, Reason}</name>
80
90
<fsummary>Start profiling.</fsummary>
82
92
<v>Rootset = [atom() | pid()]</v>
83
93
<v>Fun = fun() -> term()</v>
94
<v>Pattern = {Module, Function, Arity}</v>
84
95
<v>Module = Function = atom()</v>
85
96
<v>Args = [term()]</v>
97
<v>Arity = integer()</v>
86
98
<v>Value = Reason = term()</v>
96
108
<c>Rootset</c>, the function returns <c>{ok,Value}</c> when
97
109
<c>Fun()</c>/<c>apply</c> returns with the value <c>Value</c>, or
98
110
<c>{error,Reason}</c> if <c>Fun()</c>/<c>apply</c> fails with
99
exit reason <c>Reason</c>. Otherwise it returns <c>error</c>
111
exit reason <c>Reason</c>. Otherwise it returns <c>{error, Reason}</c>
101
113
<p>The programmer must ensure that the function given as argument
102
114
is truly synchronous and that no work continues after
107
<name>analyse()</name>
119
<name>analyze() -> ok</name>
120
<name>analyze(Type) -> ok</name>
121
<name>analyze(Type,Options) -> ok</name>
123
<v>Type = procs | total</v>
124
<v>Options = [{filter, Filter} | {sort, Sort}</v>
125
<v>Filter = [{calls, integer()} | {time, float()}]</v>
126
<v>Sort = time | calls | mfa</v>
108
128
<fsummary>Display profiling results per process.</fsummary>
110
130
<p>Call this function when profiling has been stopped to display
113
133
<item>how much time has been used by each process, and</item>
114
134
<item>in which function calls this time has been spent.</item>
116
<p>Time is shown as percentage of total time, not as absolute time.</p>
120
<name>total_analyse()</name>
121
<fsummary>Display profiling results per function call.</fsummary>
123
<p>Call this function when profiling has been stopped to display
136
<p>Call <c>analyze</c> with <c>total</c> option when profiling has been stopped to display
124
137
the results per function call, that is in which function calls
125
138
the time has been spent.</p>
126
<p>Time is shown as percentage of total time, not as absolute time.</p>
139
<p>Time is shown as percentage of total time and as absolute time.</p>