This is a static copy of a profile report

Home

validatestring (Calls: 20, Time: 0.006 s)
Generated 16-Jul-2020 17:09:40 using performance time.
function in file /Applications/MATLAB_R2020a.app/toolbox/matlab/lang/validatestring.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
imagesci/private/writepngfunction20
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
65
out = checkString(in, validStr...
200.003 s46.7%
57
[in, validStrings, optional_in...
200.002 s33.9%
79
end
200.000 s1.1%
54
narginchk(2,5);
200.000 s0.1%
56
try
200.000 s0.1%
All other lines  0.001 s18.1%
Totals  0.006 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
validatestring>checkStringsubfunction200.002 s39.0%
validatestring>checkInputssubfunction200.001 s19.0%
Self time (built-ins, overhead, etc.)  0.003 s42.0%
Totals  0.006 s100% 
Code Analyzer results
No Code Analyzer messages.
Coverage results
Show coverage for parent directory
Total lines in function79
Non-code lines (comments, blank lines)62
Code lines (lines that can run)17
Code lines that did run8
Code lines that did not run9
Coverage (did run/can run)47.06 %
Function listing
time 
Calls 
 line
   1 
function out = validatestring( varargin )
   2 
%VALIDATESTRING Check validity of text.
   3 
%   VALIDSTR = VALIDATESTRING(STR,VALID_STRINGS) checks the validity of
   4 
%   text STR. If STR unambiguously and case-insensitively matches the
   5 
%   beginning of one of VALID_STRINGS, VALIDATESTRING returns the match
   6 
%   in VALIDSTR. Otherwise, VALIDATESTRING issues a formatted error message.
   7 
%
   8 
%   VALIDSTR = VALIDATESTRING(STR,VALID_STRINGS,ARG_INDEX) includes the 
   9 
%   position of the input in your function argument list as part of any
  10 
%   generated error messages.
  11 
%
  12 
%   VALIDSTR = VALIDATESTRING(STR,VALID_STRINGS,FUNC_NAME) includes the 
  13 
%   specified function name in generated error identifiers.
  14 
%
  15 
%   VALIDSTR = VALIDATESTRING(STR,VALID_STRINGS,FUNC_NAME,VAR_NAME) includes 
  16 
%   the specified variable name in generated error messages.
  17 
%
  18 
%   VALIDSTR = VALIDATESTRING(STR,VALID_STRINGS,FUNC_NAME,VAR_NAME,ARG_INDEX) 
  19 
%   includes the specified information in the generated error messages or
  20 
%   identifiers.
  21 
%
  22 
%   Input Arguments:
  23 
%
  24 
%   VALID_STRINGS   Array of strings or cell array of character vectors.
  25 
%
  26 
%   ARG_INDEX       Positive integer that specifies the position of the
  27 
%                   input argument.
  28 
%
  29 
%   FUNC_NAME       String scalar or character vector that specifies the
  30 
%                   function name. If you specify a missing string or an
  31 
%                   empty character vector, '', FUNC_NAME is ignored.
  32 
%
  33 
%   VAR_NAME        String scalar or character vector that specifies the
  34 
%                   input argument name. If you specify a missing string or
  35 
%                   an empty character vector, '', VAR_NAME is ignored.
  36 
%
  37 
%   Example: Define a cell array of text strings, and pass in another
  38 
%            string that is not in the cell array.
  39 
%
  40 
%       validatestring('C',{'A','B'},'func_name','var_name',2)
  41 
%
  42 
%   This code throws an error and displays a formatted message:
  43 
%
  44 
%       Expected argument 2, var_name, to match one of these strings:
  45 
%
  46 
%       'A', 'B'
  47 
%
  48 
%       The input, 'C', did not match any of the valid strings.
  49 
%
  50 
%   See also validateattributes, inputParser.
  51 

  52 
%   Copyright 1993-2018 The MathWorks, Inc.
  53 

< 0.001 
     20 
  54
    narginchk(2,5); 
  55 

< 0.001 
     20 
  56
    try 
  0.002 
     20 
  57
        [in, validStrings, optional_inputs] = checkInputs(varargin); 
  58 
    catch e
  59 
        % only VALIDATESTRING should be on the stack
  60 
        throw(e)
< 0.001 
     20 
  61
    end 
  62 

< 0.001 
     20 
  63
    try     
  64 
        % check the contents of IN
  0.003 
     20 
  65
        out = checkString(in, validStrings, optional_inputs); 
  66 

  67 
    catch e
  68 
        myId = 'MATLAB:validatestring:';
  69 
        if strncmp(myId, e.identifier, length(myId))
  70 
            % leave VALIDATESTRING on the stack, because there was a misuse
  71 
            % of VALIDATESTRING itself
  72 
            throw(e)
  73 
        else
  74 
            % strip VALIDATESTRING off the stack so that the error looks like
  75 
            % it comes from the caller just as if it had hand-coded its input checking
  76 
            throwAsCaller( e )
  77 
        end
< 0.001 
     20 
  78
    end 
< 0.001 
     20 
  79
end 

Other subfunctions in this file are not included in this listing.