This is a static copy of a profile report

Home

rowNamesDim>rowNamesDim.validateAndAssignLabels (Calls: 16, Time: 0.005 s)
Generated 04-Jun-2021 04:11:15 using performance time.
class method in file C:\Program Files\MATLAB\R2020b\toolbox\matlab\datatypes\tabular\+matlab\+internal\+tabular\+private\rowNamesDim.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
...mension>tabularDimension.setLabelsclass method16
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
143
obj.checkDuplicateLabels(newLa...
70.002 s30.8%
150
obj = obj.assignLabels(newLabe...
70.001 s18.8%
128
newLabels = obj.makeValidName(...
70.001 s16.0%
105
if fullAssignment && i...
160.000 s6.8%
111
newLabels = strtrim(newLabels(...
70.000 s3.5%
All other lines  0.001 s23.9%
Totals  0.005 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
...tabularDimension.checkDuplicateLabelsclass method70.001 s24.8%
rowNamesDim>rowNamesDim.makeValidNameclass method70.001 s12.5%
...sion>tabularDimension.assignLabelsclass method70.001 s11.7%
Self time (built-ins, overhead, etc.)  0.003 s51.1%
Totals  0.005 s100% 
Code Analyzer results
No Code Analyzer messages.
Coverage results
Show coverage for parent directory
Total lines in function59
Non-code lines (comments, blank lines)16
Code lines (lines that can run)43
Code lines that did run23
Code lines that did not run20
Coverage (did run/can run)53.49 %
Function listing
time 
Calls 
 line
  96 
        function obj = validateAndAssignLabels(obj,newLabels,rowIndices,fullAssignment,fixDups,fixEmpties,fixIllegal)
  97 
            import matlab.internal.datatypes.isCharString
  98 
            import matlab.internal.datatypes.isCharStrings
  99 
            import matlab.internal.tabular.private.rowNamesDim.checkReservedNames;
< 0.001 
     16 
 100
            try 
< 0.001 
     16 
 101
                if ~fullAssignment && isCharString(newLabels,fixEmpties) 
 102 
                    % Accept one character vector for (partial) assignment to one name, allow empty character vectors per caller.
 103 
                    newLabels = { strtrim(newLabels) };
< 0.001 
     16 
 104
                elseif isCharStrings(newLabels,true,fixEmpties) 
< 0.001 
     16 
 105
                    if fullAssignment && isequal(newLabels,{}) % Accept {} to remove row names 
< 0.001 
      9 
 106
                        obj.labels = {}; % force a 0x0, for cosmetics 
< 0.001 
      9 
 107
                        obj.hasLabels = false; 
< 0.001 
      9 
 108
                        return 
< 0.001 
      7 
 109
                    end 
 110 
                    % Accept a cellstr, allow empty character vectors per caller.
< 0.001 
      7 
 111
                    newLabels = strtrim(newLabels(:)); % a col vector, conveniently forces any empty to 0x1 
 112 
                else
 113 
                    error(message('MATLAB:table:InvalidRowNames'));
< 0.001 
      7 
 114
                end 
 115 
                
< 0.001 
      7 
 116
                if fixEmpties 
 117 
                    % Fill in empty names if allowed, and make them unique with respect
 118 
                    % to the other new names. If not allowed, an error was already thrown.
 119 
                    [newLabels,wasEmpty] = fillEmptyNames(newLabels,rowIndices);
 120 
                    newLabels = matlab.lang.makeUniqueStrings(newLabels,wasEmpty,namelengthmax);
< 0.001 
      7 
 121
                end 
 122 
                
< 0.001 
      7 
 123
                if ~fixIllegal 
< 0.001 
      7 
 124
                    exceptionMode = 'error'; 
 125 
                else
 126 
                    exceptionMode = 'silent';
< 0.001 
      7 
 127
                end 
< 0.001 
      7 
 128
                newLabels = obj.makeValidName(newLabels,exceptionMode); 
 129 

 130 
                
< 0.001 
      7 
 131
                if fixDups 
 132 
                    % Make the new names unique with respect to each other and to existing names (if any).
 133 
                    newAndOldLabels = obj.labels;
 134 
                    if isempty(newAndOldLabels)
 135 
                        newLabels = matlab.lang.makeUniqueStrings(newLabels,1:length(newLabels),inf);
 136 
                    else
 137 
                        newAndOldLabels(rowIndices) = newLabels;
 138 
                        newAndOldLabels = matlab.lang.makeUniqueStrings(newAndOldLabels,rowIndices,inf);
 139 
                        newLabels = newAndOldLabels(rowIndices);
 140 
                    end
< 0.001 
      7 
 141
                elseif fullAssignment 
 142 
                    % Check that the whole set of new names is unique
  0.002 
      7 
 143
                    obj.checkDuplicateLabels(newLabels); 
 144 
                else
 145 
                    % Check that the new names do not duplicate each other or existing names.
 146 
                    newAndOldLabels = obj.labels; newAndOldLabels(rowIndices) = newLabels;
 147 
                    obj.checkDuplicateLabels(newLabels,newAndOldLabels,rowIndices);
< 0.001 
      7 
 148
                end 
 149 
                
  0.001 
      7 
 150
                obj = obj.assignLabels(newLabels,fullAssignment,rowIndices); 
 151 
            catch ME
 152 
                throwAsCaller(ME);
< 0.001 
      7 
 153
            end 
< 0.001 
      7 
 154
        end 

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