Mercurial > hg > octave-lyh
annotate doc/interpreter/debug.txi @ 14119:94e2a76f1e5a stable
doc: Final grammarcheck and spellcheck before 3.6.0 release.
* container.txi, aspell-octave.en.pws, expr.txi, vectorize.txi, accumarray.m,
accumdim.m, interpft.m, strread.m, parseparams.m, warning_ids.m, cellfun.cc,
help.cc: grammarcheck and spellcheck docstrings.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Thu, 29 Dec 2011 06:05:00 -0800 |
parents | b0cdd60db5e5 |
children | 72c96de7a403 |
rev | line source |
---|---|
11523 | 1 @c Copyright (C) 1996-2011 John W. Eaton |
7018 | 2 @c |
3 @c This file is part of Octave. | |
4 @c | |
5 @c Octave is free software; you can redistribute it and/or modify it | |
6 @c under the terms of the GNU General Public License as published by the | |
7 @c Free Software Foundation; either version 3 of the License, or (at | |
8 @c your option) any later version. | |
9 @c | |
10 @c Octave is distributed in the hope that it will be useful, but WITHOUT | |
11 @c ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
12 @c FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
13 @c for more details. | |
14 @c | |
15 @c You should have received a copy of the GNU General Public License | |
16 @c along with Octave; see the file COPYING. If not, see | |
17 @c <http://www.gnu.org/licenses/>. | |
4175 | 18 |
19 @node Debugging | |
20 @chapter Debugging | |
21 | |
6646 | 22 Octave includes a built-in debugger to aid in the development of |
9039
51dc9691f23f
Cleanup documentation files errors.texi, debug.texi, io.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
23 scripts. This can be used to interrupt the execution of an Octave script |
51dc9691f23f
Cleanup documentation files errors.texi, debug.texi, io.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
24 at a certain point, or when certain conditions are met. Once execution |
6646 | 25 has stopped, and debug mode is entered, the symbol table at the point |
26 where execution has stopped can be examined and modified to check for | |
27 errors. | |
4175 | 28 |
8485
2beb59bf773a
[docs] commandline => command-line
Brian Gough <bjg@gnu.org>
parents:
8347
diff
changeset
|
29 The normal command-line editing and history functions are available in |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
30 debug mode. |
6646 | 31 |
32 @menu | |
33 * Entering Debug Mode:: | |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
34 * Leaving Debug Mode:: |
6646 | 35 * Breakpoints:: |
36 * Debug Mode:: | |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
37 * Call Stack:: |
12976
2e20c26b1007
Document the profiler functions.
Daniel Kraft <d@domob.eu>
parents:
12632
diff
changeset
|
38 * Profiling:: |
12978
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
39 * Profiler Example:: |
6646 | 40 @end menu |
4175 | 41 |
6646 | 42 @node Entering Debug Mode |
43 @section Entering Debug Mode | |
4175 | 44 |
6646 | 45 There are two basic means of interrupting the execution of an Octave |
9039
51dc9691f23f
Cleanup documentation files errors.texi, debug.texi, io.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
46 script. These are breakpoints @pxref{Breakpoints}, discussed in the next |
6646 | 47 section and interruption based on some condition. |
48 | |
49 Octave supports three means to stop execution based on the values set in | |
50 the functions @code{debug_on_interrupt}, @code{debug_on_warning} and | |
51 @code{debug_on_error}. | |
4175 | 52 |
4185 | 53 @DOCSTRING(debug_on_interrupt) |
4175 | 54 |
55 @DOCSTRING(debug_on_warning) | |
4185 | 56 |
57 @DOCSTRING(debug_on_error) | |
6646 | 58 |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
59 @node Leaving Debug Mode |
10791
3140cb7a05a1
Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
9209
diff
changeset
|
60 @section Leaving Debug Mode |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
61 |
8828 | 62 To leave the debug mode, use either @code{dbcont} |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
63 or @code{return}. |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
64 |
8275 | 65 @DOCSTRING(dbcont) |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
66 |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
67 To quit debug mode and return directly to the prompt @code{dbquit} |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
68 should be used instead |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
69 |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
70 @DOCSTRING(dbquit) |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
71 |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
72 Finally, typing @code{exit} or @code{quit} at the debug prompt will |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
73 result in Octave terminating normally. |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
74 |
6646 | 75 @node Breakpoints |
76 @section Breakpoints | |
77 | |
78 Breakpoints can be set in any Octave function, using the @code{dbstop} | |
79 function. | |
80 | |
81 @DOCSTRING(dbstop) | |
82 | |
83 @noindent | |
8347
fa78cb8d8a5c
corrections for typos
Brian Gough<bjg@network-theory.co.uk>
parents:
8286
diff
changeset
|
84 Note that breakpoints cannot be set in built-in functions |
9209
923c7cb7f13f
Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
Rik <rdrider0-list@yahoo.com>
parents:
9039
diff
changeset
|
85 (e.g., @code{sin}, etc.) or dynamically loaded function (i.e., oct-files). To |
6646 | 86 set a breakpoint immediately on entering a function, the breakpoint |
87 should be set to line 1. The leading comment block will be ignored and | |
88 the breakpoint will be set to the first executable statement in the | |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
89 function. For example: |
6646 | 90 |
91 @example | |
92 @group | |
93 dbstop ("asind", 1) | |
12632
2dbac27e0e40
doc: miscellaneous touch-ups to documentation strings
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
94 @result{} 28 |
6646 | 95 @end group |
96 @end example | |
97 | |
98 @noindent | |
99 Note that the return value of @code{27} means that the breakpoint was | |
9209
923c7cb7f13f
Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
Rik <rdrider0-list@yahoo.com>
parents:
9039
diff
changeset
|
100 effectively set to line 27. The status of breakpoints in a function can |
6646 | 101 be queried with the @code{dbstatus} function. |
102 | |
103 @DOCSTRING(dbstatus) | |
104 | |
105 @noindent | |
106 Taking the above as an example, @code{dbstatus ("asind")} should return | |
12632
2dbac27e0e40
doc: miscellaneous touch-ups to documentation strings
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
107 28. The breakpoints can then be cleared with the @code{dbclear} function |
6646 | 108 |
109 @DOCSTRING(dbclear) | |
110 | |
111 @noindent | |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
112 These functions can be used to clear all the breakpoints in a function. For |
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
113 example: |
6646 | 114 |
115 @example | |
116 dbclear ("asind", dbstatus ("asind")); | |
117 @end example | |
118 | |
9039
51dc9691f23f
Cleanup documentation files errors.texi, debug.texi, io.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
119 A breakpoint can be set in a subfunction. For example if a file contains |
7984
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
120 the functions |
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
121 |
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
122 @example |
9209
923c7cb7f13f
Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
Rik <rdrider0-list@yahoo.com>
parents:
9039
diff
changeset
|
123 @group |
7984
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
124 function y = func1 (x) |
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
125 y = func2 (x); |
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
126 endfunction |
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
127 function y = func2 (x) |
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
128 y = x + 1; |
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
129 endfunction |
9209
923c7cb7f13f
Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
Rik <rdrider0-list@yahoo.com>
parents:
9039
diff
changeset
|
130 @end group |
7984
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
131 @end example |
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
132 |
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
133 @noindent |
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
134 then a breakpoint can be set at the start of the subfunction directly |
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
135 with |
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
136 |
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
137 @example |
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
138 @group |
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
139 dbstop (["func1", filemarker(), "func2"]) |
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
140 @result{} 5 |
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
141 @end group |
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
142 @end example |
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
143 |
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
144 Note that @code{filemarker} returns a character that marks the |
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
145 subfunctions from the file containing them. |
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
146 |
8828 | 147 Another simple way of setting a breakpoint in an Octave script is the |
6646 | 148 use of the @code{keyboard} function. |
149 | |
150 @DOCSTRING(keyboard) | |
151 | |
152 @noindent | |
153 The @code{keyboard} function is typically placed in a script at the | |
9039
51dc9691f23f
Cleanup documentation files errors.texi, debug.texi, io.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
154 point where the user desires that the execution is stopped. It |
6646 | 155 automatically sets the running script into the debug mode. |
156 | |
157 @node Debug Mode | |
158 @section Debug Mode | |
159 | |
160 There are two additional support functions that allow the user to | |
161 interrogate where in the execution of a script Octave entered the debug | |
162 mode and to print the code in the script surrounding the point where | |
163 Octave entered debug mode. | |
164 | |
165 @DOCSTRING(dbwhere) | |
166 | |
167 @DOCSTRING(dbtype) | |
6647 | 168 |
8817
03b7f618ab3d
include docstrings for new functions in the manual
John W. Eaton <jwe@octave.org>
parents:
8485
diff
changeset
|
169 You may also use @code{isdebugmode} to determine whether the debugger is |
03b7f618ab3d
include docstrings for new functions in the manual
John W. Eaton <jwe@octave.org>
parents:
8485
diff
changeset
|
170 currently active. |
03b7f618ab3d
include docstrings for new functions in the manual
John W. Eaton <jwe@octave.org>
parents:
8485
diff
changeset
|
171 |
03b7f618ab3d
include docstrings for new functions in the manual
John W. Eaton <jwe@octave.org>
parents:
8485
diff
changeset
|
172 @DOCSTRING(isdebugmode) |
03b7f618ab3d
include docstrings for new functions in the manual
John W. Eaton <jwe@octave.org>
parents:
8485
diff
changeset
|
173 |
8828 | 174 Debug mode also allows single line stepping through a function using |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
175 the commands @code{dbstep}. |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
176 |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
177 @DOCSTRING(dbstep) |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
178 |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
179 @node Call Stack |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
180 @section Call Stack |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
181 |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
182 @DOCSTRING(dbstack) |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
183 |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
184 @DOCSTRING(dbup) |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
185 |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
186 @DOCSTRING(dbdown) |
12976
2e20c26b1007
Document the profiler functions.
Daniel Kraft <d@domob.eu>
parents:
12632
diff
changeset
|
187 |
2e20c26b1007
Document the profiler functions.
Daniel Kraft <d@domob.eu>
parents:
12632
diff
changeset
|
188 @node Profiling |
2e20c26b1007
Document the profiler functions.
Daniel Kraft <d@domob.eu>
parents:
12632
diff
changeset
|
189 @section Profiling |
2e20c26b1007
Document the profiler functions.
Daniel Kraft <d@domob.eu>
parents:
12632
diff
changeset
|
190 @cindex profiler |
2e20c26b1007
Document the profiler functions.
Daniel Kraft <d@domob.eu>
parents:
12632
diff
changeset
|
191 @cindex code profiling |
2e20c26b1007
Document the profiler functions.
Daniel Kraft <d@domob.eu>
parents:
12632
diff
changeset
|
192 |
14038
b0cdd60db5e5
doc: Grammarcheck documentation ahead of 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents:
13931
diff
changeset
|
193 Octave supports profiling of code execution on a per-function level. If |
12976
2e20c26b1007
Document the profiler functions.
Daniel Kraft <d@domob.eu>
parents:
12632
diff
changeset
|
194 profiling is enabled, each call to a function (supporting built-ins, |
12979
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
195 operators, functions in oct- and mex-files, user-defined functions in |
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
196 Octave code and anonymous functions) is recorded while running Octave |
14038
b0cdd60db5e5
doc: Grammarcheck documentation ahead of 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents:
13931
diff
changeset
|
197 code. After that, this data can aid in analyzing the code behavior, and |
12979
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
198 is in particular helpful for finding ``hot spots'' in the code which use |
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
199 up a lot of computation time and are the best targets to spend |
12976
2e20c26b1007
Document the profiler functions.
Daniel Kraft <d@domob.eu>
parents:
12632
diff
changeset
|
200 optimization efforts on. |
2e20c26b1007
Document the profiler functions.
Daniel Kraft <d@domob.eu>
parents:
12632
diff
changeset
|
201 |
12979
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
202 The main command for profiling is @code{profile}, which can be used to |
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
203 start or stop the profiler and also to query collected data afterwards. |
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
204 The data is returned in an Octave data structure which can then be |
12976
2e20c26b1007
Document the profiler functions.
Daniel Kraft <d@domob.eu>
parents:
12632
diff
changeset
|
205 examined or further processed by other routines or tools. |
2e20c26b1007
Document the profiler functions.
Daniel Kraft <d@domob.eu>
parents:
12632
diff
changeset
|
206 |
2e20c26b1007
Document the profiler functions.
Daniel Kraft <d@domob.eu>
parents:
12632
diff
changeset
|
207 @DOCSTRING(profile) |
2e20c26b1007
Document the profiler functions.
Daniel Kraft <d@domob.eu>
parents:
12632
diff
changeset
|
208 |
12979
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
209 An easy way to get an overview over the collected data is |
14038
b0cdd60db5e5
doc: Grammarcheck documentation ahead of 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents:
13931
diff
changeset
|
210 @code{profshow}. This function takes the profiler data returned by |
12979
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
211 @code{profile} as input and prints a flat profile, for instance: |
12976
2e20c26b1007
Document the profiler functions.
Daniel Kraft <d@domob.eu>
parents:
12632
diff
changeset
|
212 |
2e20c26b1007
Document the profiler functions.
Daniel Kraft <d@domob.eu>
parents:
12632
diff
changeset
|
213 @example |
12979
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
214 @group |
12976
2e20c26b1007
Document the profiler functions.
Daniel Kraft <d@domob.eu>
parents:
12632
diff
changeset
|
215 Function Attr Time (s) Calls |
2e20c26b1007
Document the profiler functions.
Daniel Kraft <d@domob.eu>
parents:
12632
diff
changeset
|
216 ---------------------------------------- |
2e20c26b1007
Document the profiler functions.
Daniel Kraft <d@domob.eu>
parents:
12632
diff
changeset
|
217 >myfib R 2.195 13529 |
2e20c26b1007
Document the profiler functions.
Daniel Kraft <d@domob.eu>
parents:
12632
diff
changeset
|
218 binary <= 0.061 13529 |
2e20c26b1007
Document the profiler functions.
Daniel Kraft <d@domob.eu>
parents:
12632
diff
changeset
|
219 binary - 0.050 13528 |
2e20c26b1007
Document the profiler functions.
Daniel Kraft <d@domob.eu>
parents:
12632
diff
changeset
|
220 binary + 0.026 6764 |
12979
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
221 @end group |
12976
2e20c26b1007
Document the profiler functions.
Daniel Kraft <d@domob.eu>
parents:
12632
diff
changeset
|
222 @end example |
2e20c26b1007
Document the profiler functions.
Daniel Kraft <d@domob.eu>
parents:
12632
diff
changeset
|
223 |
13931
9de488c6c59c
doc: Spellcheck documentation before 3.6.0 release
Rik <octave@nomad.inbox5.com>
parents:
13195
diff
changeset
|
224 This shows that most of the run time was spent executing the function |
12979
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
225 @samp{myfib}, and some minor proportion evaluating the listed binary |
14038
b0cdd60db5e5
doc: Grammarcheck documentation ahead of 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents:
13931
diff
changeset
|
226 operators. Furthermore, it is shown how often the function was called |
12979
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
227 and the profiler also records that it is recursive. |
12976
2e20c26b1007
Document the profiler functions.
Daniel Kraft <d@domob.eu>
parents:
12632
diff
changeset
|
228 |
2e20c26b1007
Document the profiler functions.
Daniel Kraft <d@domob.eu>
parents:
12632
diff
changeset
|
229 @DOCSTRING(profshow) |
12978
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
230 |
13195
08650b6fbf67
document profexplore and include it in the list of files to distribute
John W. Eaton <jwe@octave.org>
parents:
12979
diff
changeset
|
231 @DOCSTRING(profexplore) |
08650b6fbf67
document profexplore and include it in the list of files to distribute
John W. Eaton <jwe@octave.org>
parents:
12979
diff
changeset
|
232 |
12978
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
233 @node Profiler Example |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
234 @section Profiler Example |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
235 |
14038
b0cdd60db5e5
doc: Grammarcheck documentation ahead of 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents:
13931
diff
changeset
|
236 Below, we will give a short example of a profiler session. See also |
12979
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
237 @ref{Profiling} for the documentation of the profiler functions in |
14038
b0cdd60db5e5
doc: Grammarcheck documentation ahead of 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents:
13931
diff
changeset
|
238 detail. Consider the code: |
12978
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
239 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
240 @example |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
241 global N A; |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
242 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
243 N = 300; |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
244 A = rand (N, N); |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
245 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
246 function xt = timesteps (steps, x0, expM) |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
247 global N; |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
248 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
249 if (steps == 0) |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
250 xt = NA (N, 0); |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
251 else |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
252 xt = NA (N, steps); |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
253 x1 = expM * x0; |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
254 xt(:, 1) = x1; |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
255 xt(:, 2 : end) = timesteps (steps - 1, x1, expM); |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
256 endif |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
257 endfunction |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
258 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
259 function foo () |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
260 global N A; |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
261 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
262 initial = @@(x) sin (x); |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
263 x0 = (initial (linspace (0, 2 * pi, N)))'; |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
264 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
265 expA = expm (A); |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
266 xt = timesteps (100, x0, expA); |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
267 endfunction |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
268 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
269 function fib = bar (N) |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
270 if (N <= 2) |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
271 fib = 1; |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
272 else |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
273 fib = bar (N - 1) + bar (N - 2); |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
274 endif |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
275 endfunction |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
276 @end example |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
277 |
12979
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
278 If we execute the two main functions, we get: |
12978
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
279 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
280 @example |
12979
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
281 @group |
12978
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
282 tic; foo; toc; |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
283 @result{} Elapsed time is 2.37338 seconds. |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
284 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
285 tic; bar (20); toc; |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
286 @result{} Elapsed time is 2.04952 seconds. |
12979
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
287 @end group |
12978
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
288 @end example |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
289 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
290 But this does not give much information about where this time is spent; |
12979
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
291 for instance, whether the single call to @code{expm} is more expensive |
14038
b0cdd60db5e5
doc: Grammarcheck documentation ahead of 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents:
13931
diff
changeset
|
292 or the recursive time-stepping itself. To get a more detailed picture, |
12978
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
293 we can use the profiler. |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
294 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
295 @example |
12979
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
296 @group |
12978
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
297 profile on; |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
298 foo; |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
299 profile off; |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
300 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
301 data = profile ('info'); |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
302 profshow (data, 10); |
12979
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
303 @end group |
12978
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
304 @end example |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
305 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
306 This prints a table like: |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
307 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
308 @example |
12979
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
309 @group |
12978
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
310 # Function Attr Time (s) Calls |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
311 --------------------------------------------- |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
312 7 expm 1.034 1 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
313 3 binary * 0.823 117 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
314 41 binary \ 0.188 1 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
315 38 binary ^ 0.126 2 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
316 43 timesteps R 0.111 101 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
317 44 NA 0.029 101 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
318 39 binary + 0.024 8 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
319 34 norm 0.011 1 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
320 40 binary - 0.004 101 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
321 33 balance 0.003 1 |
12979
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
322 @end group |
12978
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
323 @end example |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
324 |
12979
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
325 The entries are the individual functions which have been executed (only |
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
326 the 10 most important ones), together with some information for each of |
14038
b0cdd60db5e5
doc: Grammarcheck documentation ahead of 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents:
13931
diff
changeset
|
327 them. The entries like @samp{binary *} denote operators, while other |
b0cdd60db5e5
doc: Grammarcheck documentation ahead of 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents:
13931
diff
changeset
|
328 entries are ordinary functions. They include both built-ins like |
b0cdd60db5e5
doc: Grammarcheck documentation ahead of 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents:
13931
diff
changeset
|
329 @code{expm} and our own routines (for instance @code{timesteps}). From |
12979
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
330 this profile, we can immediately deduce that @code{expm} uses up the |
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
331 largest proportion of the processing time, even though it is only called |
14038
b0cdd60db5e5
doc: Grammarcheck documentation ahead of 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents:
13931
diff
changeset
|
332 once. The second expensive operation is the matrix-vector product in the |
b0cdd60db5e5
doc: Grammarcheck documentation ahead of 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents:
13931
diff
changeset
|
333 routine @code{timesteps}. @footnote{We only know it is the binary |
12979
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
334 multiplication operator, but fortunately this operator appears only at |
13931
9de488c6c59c
doc: Spellcheck documentation before 3.6.0 release
Rik <octave@nomad.inbox5.com>
parents:
13195
diff
changeset
|
335 one place in the code and thus we know which occurrence takes so much |
14038
b0cdd60db5e5
doc: Grammarcheck documentation ahead of 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents:
13931
diff
changeset
|
336 time. If there were multiple places, we would have to use the |
12979
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
337 hierarchical profile to find out the exact place which uses up the time |
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
338 which is not covered in this example.} |
12978
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
339 |
12979
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
340 Timing, however, is not the only information available from the profile. |
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
341 The attribute column shows us that @code{timesteps} calls itself |
14038
b0cdd60db5e5
doc: Grammarcheck documentation ahead of 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents:
13931
diff
changeset
|
342 recursively. This may not be that remarkable in this example (since it's |
b0cdd60db5e5
doc: Grammarcheck documentation ahead of 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents:
13931
diff
changeset
|
343 clear anyway), but could be helpful in a more complex setting. As to the |
12979
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
344 question of why is there a @samp{binary \} in the output, we can easily |
14038
b0cdd60db5e5
doc: Grammarcheck documentation ahead of 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents:
13931
diff
changeset
|
345 shed some light on that too. Note that @code{data} is a structure array |
12979
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
346 (@ref{Structure Arrays}) which contains the field @code{FunctionTable}. |
14038
b0cdd60db5e5
doc: Grammarcheck documentation ahead of 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents:
13931
diff
changeset
|
347 This stores the raw data for the profile shown. The number in the first |
12979
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
348 column of the table gives the index under which the shown function can |
14038
b0cdd60db5e5
doc: Grammarcheck documentation ahead of 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents:
13931
diff
changeset
|
349 be found there. Looking up @code{data.FunctionTable(41)} gives: |
12978
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
350 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
351 @example |
12979
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
352 @group |
12978
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
353 scalar structure containing the fields: |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
354 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
355 FunctionName = binary \ |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
356 TotalTime = 0.18765 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
357 NumCalls = 1 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
358 IsRecursive = 0 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
359 Parents = 7 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
360 Children = [](1x0) |
12979
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
361 @end group |
12978
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
362 @end example |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
363 |
12979
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
364 Here we see the information from the table again, but have additional |
14038
b0cdd60db5e5
doc: Grammarcheck documentation ahead of 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents:
13931
diff
changeset
|
365 fields @code{Parents} and @code{Children}. Those are both arrays, which |
12979
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
366 contain the indices of functions which have directly called the function |
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
367 in question (which is entry 7, @code{expm}, in this case) or been called |
14038
b0cdd60db5e5
doc: Grammarcheck documentation ahead of 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents:
13931
diff
changeset
|
368 by it (no functions). Hence, the backslash operator has been used |
12979
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
369 internally by @code{expm}. |
12978
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
370 |
14038
b0cdd60db5e5
doc: Grammarcheck documentation ahead of 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents:
13931
diff
changeset
|
371 Now let's take a look at @code{bar}. For this, we start a fresh |
12979
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
372 profiling session (@code{profile on} does this; the old data is removed |
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
373 before the profiler is restarted): |
12978
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
374 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
375 @example |
12979
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
376 @group |
12978
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
377 profile on; |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
378 bar (20); |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
379 profile off; |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
380 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
381 profshow (profile ('info')); |
12979
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
382 @end group |
12978
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
383 @end example |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
384 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
385 This gives: |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
386 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
387 @example |
14038
b0cdd60db5e5
doc: Grammarcheck documentation ahead of 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents:
13931
diff
changeset
|
388 @group |
12978
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
389 # Function Attr Time (s) Calls |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
390 ------------------------------------------------------- |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
391 1 bar R 2.091 13529 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
392 2 binary <= 0.062 13529 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
393 3 binary - 0.042 13528 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
394 4 binary + 0.023 6764 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
395 5 profile 0.000 1 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
396 8 false 0.000 1 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
397 6 nargin 0.000 1 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
398 7 binary != 0.000 1 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
399 9 __profiler_enable__ 0.000 1 |
14038
b0cdd60db5e5
doc: Grammarcheck documentation ahead of 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents:
13931
diff
changeset
|
400 @end group |
12978
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
401 @end example |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
402 |
14038
b0cdd60db5e5
doc: Grammarcheck documentation ahead of 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents:
13931
diff
changeset
|
403 Unsurprisingly, @code{bar} is also recursive. It has been called 13,529 |
12979
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
404 times in the course of recursively calculating the Fibonacci number in a |
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
405 suboptimal way, and most of the time was spent in @code{bar} itself. |
12978
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
406 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
407 Finally, let's say we want to profile the execution of both @code{foo} |
14038
b0cdd60db5e5
doc: Grammarcheck documentation ahead of 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents:
13931
diff
changeset
|
408 and @code{bar} together. Since we already have the run-time data |
12979
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
409 collected for @code{bar}, we can restart the profiler without clearing |
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
410 the existing data and collect the missing statistics about @code{foo}. |
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
411 This is done by: |
12978
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
412 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
413 @example |
12979
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
414 @group |
12978
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
415 profile resume; |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
416 foo; |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
417 profile off; |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
418 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
419 profshow (profile ('info'), 10); |
12979
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
420 @end group |
12978
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
421 @end example |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
422 |
12979
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
423 As you can see in the table below, now we have both profiles mixed |
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
424 together. |
12978
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
425 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
426 @example |
12979
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
427 @group |
12978
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
428 # Function Attr Time (s) Calls |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
429 --------------------------------------------- |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
430 1 bar R 2.091 13529 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
431 16 expm 1.122 1 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
432 12 binary * 0.798 117 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
433 46 binary \ 0.185 1 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
434 45 binary ^ 0.124 2 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
435 48 timesteps R 0.115 101 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
436 2 binary <= 0.062 13529 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
437 3 binary - 0.045 13629 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
438 4 binary + 0.041 6772 |
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
439 49 NA 0.036 101 |
12979
6a9fbeff3368
Proofread profiler documentation
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12978
diff
changeset
|
440 @end group |
12978
fb0f40cd8752
Add an example profiler session to the manual.
Daniel Kraft <d@domob.eu>
parents:
12976
diff
changeset
|
441 @end example |