Mercurial > octave-nkf
comparison scripts/general/profile.m @ 12872:031e1a2c26f3
Vectorize and use Octave coding conventions for profile script files
* profile.m: Add nargin check at input. Add warning message for
unrecognized option.
* profshow.m: Add input validation for nargin and n. Use # instead
of % for comment character. Vectorize two for loops.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Fri, 22 Jul 2011 15:30:52 -0700 |
parents | 23377c46516b |
children | 05941540287c |
comparison
equal
deleted
inserted
replaced
12871:23377c46516b | 12872:031e1a2c26f3 |
---|---|
15 ## You should have received a copy of the GNU General Public License | 15 ## You should have received a copy of the GNU General Public License |
16 ## along with Octave; see the file COPYING. If not, see | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | 17 ## <http://www.gnu.org/licenses/>. |
18 | 18 |
19 ## -*- texinfo -*- | 19 ## -*- texinfo -*- |
20 ## @deftypefn {Function File} {} profile on | 20 ## @deftypefn {Function File} {} profile on |
21 ## @deftypefnx {Function File} {} profile off | 21 ## @deftypefnx {Function File} {} profile off |
22 ## @deftypefnx {Function File} {} profile resume | 22 ## @deftypefnx {Function File} {} profile resume |
23 ## @deftypefnx {Function File} {} profile clear | 23 ## @deftypefnx {Function File} {} profile clear |
24 ## @deftypefnx {Function File} {@var{S} =} profile ('status') | 24 ## @deftypefnx {Function File} {@var{S} =} profile ('status') |
25 ## @deftypefnx {Function File} {@var{T} =} profile ('info') | 25 ## @deftypefnx {Function File} {@var{T} =} profile ('info') |
57 ## Built-in profiler. | 57 ## Built-in profiler. |
58 ## Author: Daniel Kraft <d@domob.eu> | 58 ## Author: Daniel Kraft <d@domob.eu> |
59 | 59 |
60 function retval = profile (option) | 60 function retval = profile (option) |
61 | 61 |
62 if (nargin != 1) | |
63 print_usage (); | |
64 endif | |
65 | |
62 switch (option) | 66 switch (option) |
63 case 'on' | 67 case 'on' |
64 __profiler_reset (); | 68 __profiler_reset (); |
65 __profiler_enable (true); | 69 __profiler_enable (true); |
66 | 70 |
85 case 'info' | 89 case 'info' |
86 data = __profiler_data (); | 90 data = __profiler_data (); |
87 retval = struct ('FunctionTable', data); | 91 retval = struct ('FunctionTable', data); |
88 | 92 |
89 otherwise | 93 otherwise |
94 warning ("profile: Unrecognized option '%s'", option); | |
90 print_usage (); | 95 print_usage (); |
96 | |
91 endswitch | 97 endswitch |
92 | 98 |
93 endfunction | 99 endfunction |
100 | |
94 | 101 |
95 %!demo | 102 %!demo |
96 %! profile ('on'); | 103 %! profile ('on'); |
97 %! A = rand (100); | 104 %! A = rand (100); |
98 %! B = expm (A); | 105 %! B = expm (A); |