Mercurial > hg > octave-nkf
diff 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 |
line wrap: on
line diff
--- a/scripts/general/profile.m +++ b/scripts/general/profile.m @@ -17,7 +17,7 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {} profile on +## @deftypefn {Function File} {} profile on ## @deftypefnx {Function File} {} profile off ## @deftypefnx {Function File} {} profile resume ## @deftypefnx {Function File} {} profile clear @@ -59,6 +59,10 @@ function retval = profile (option) + if (nargin != 1) + print_usage (); + endif + switch (option) case 'on' __profiler_reset (); @@ -87,11 +91,14 @@ retval = struct ('FunctionTable', data); otherwise + warning ("profile: Unrecognized option '%s'", option); print_usage (); + endswitch endfunction + %!demo %! profile ('on'); %! A = rand (100);