This is a static copy of a profile report

Home

opaque.string>jstring2string (Calls: 1, Time: 0.000 s)
Generated 18-May-2021 16:05:19 using performance time.
nested function in file /usr/local/MATLAB/R2021a/toolbox/matlab/datatypes/@opaque/string.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
opaque.stringfunction1
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
24
cel = cell(jstr);
10.000 s35.4%
19
if isempty(jstr)
10.000 s23.2%
38
str = string(cel);
10.000 s16.9%
25
if ~iscellstr(cel)
10.000 s11.0%
41
end
10.000 s2.5%
All other lines  0.000 s11.0%
Totals  0.000 s100% 
Children (called functions)
No children
Code Analyzer results
No Code Analyzer messages.
Coverage results
Show coverage for parent directory
Total lines in function26
Non-code lines (comments, blank lines)9
Code lines (lines that can run)17
Code lines that did run9
Code lines that did not run8
Coverage (did run/can run)52.94 %
Function listing
time 
Calls 
 line
  16 
    function str = jstring2string(jstr)
  17 
    % Convert a Java string vector or scalar into a string vector.  Input may be
  18 
    % null, or may have null elements, which get converted to <missing>.
< 0.001 
      1 
  19
        if isempty(jstr) 
  20 
            str = string(NaN);
< 0.001 
      1 
  21
        else 
  22 
            % we don't have a builtin to directly convert a Java String scalar or
  23 
            % vector to a string, but we can convert it to a cell array of chars.
< 0.001 
      1 
  24
            cel = cell(jstr); 
< 0.001 
      1 
  25
            if ~iscellstr(cel) 
  26 
                % If it's not a cellstr, it's because it had [] cells where
  27 
                % the input had nulls, so convert one cell at a time. 
  28 
                str(length(cel)) = string(NaN); % preallocate with <missing>
  29 
                for i = 1 : length(cel)
  30 
                    ch = cel{i};
  31 
                    if ischar(ch)
  32 
                        % if not char, it must be [] which stays <missing>
  33 
                        str(i) = string(ch);
  34 
                    end
  35 
                end
< 0.001 
      1 
  36
            else 
  37 
                % convert the cellstr to a string all at once
< 0.001 
      1 
  38
                str = string(cel); 
< 0.001 
      1 
  39
            end 
< 0.001 
      1 
  40
        end 
< 0.001 
      1 
  41
    end 

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