This is a static copy of a profile report

Home

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

Parents (calling functions)

Function NameFunction TypeCalls
varNamesDim>varNamesDim.subs2indsclass method110429
tabular.subsrefParensfunction70595
tabular.subsrefBracesfunction37754
tabular.subsasgnParensfunction1292
tabular.subsrefDotfunction5390
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
290
updatedObj = obj.selectFrom(in...
1088592.331 s52.0%
374
indices = obj.orientAs(indices...
2254600.580 s12.9%
379
end
2254600.226 s5.0%
311
elseif isColon(subscripts)
757630.175 s3.9%
331
[subscripts,indices] = obj.val...
56680.174 s3.9%
All other lines  0.997 s22.2%
Totals  4.484 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
...ension>tabularDimension.selectFromclass method705951.130 s25.2%
varNamesDim>varNamesDim.selectFromclass method382641.071 s23.9%
...larDimension.validateNativeSubscriptsclass method56680.152 s3.4%
rowNamesDim>rowNamesDim.orientAsclass method1150310.144 s3.2%
varNamesDim>varNamesDim.orientAsclass method1104290.134 s3.0%
isColonfunction757630.083 s1.9%
Self time (built-ins, overhead, etc.)  1.770 s39.5%
Totals  4.484 s100% 
Code Analyzer results
No Code Analyzer messages.
Coverage results
Show coverage for parent directory
Total lines in function142
Non-code lines (comments, blank lines)30
Code lines (lines that can run)112
Code lines that did run63
Code lines that did not run49
Coverage (did run/can run)56.25 %
Function listing
time 
Calls 
 line
 238 
        function [indices,numIndices,maxIndex,isLiteralColon,isLabels,updatedObj] ...
 239 
                     = subs2inds(obj,subscripts,subsType)
 240 
            %SUBS2INDS Convert table subscripts (labels, logical, numeric) to indices.
 241 
            
 242 
            import matlab.internal.datatypes.isColon
 243 
            
  0.014 
 225460 
 244
            try 
  0.094 
 225460 
 245
                if nargin < 3, subsType = obj.subsType.reference; end 
 246 
                
 247 
                % Translate a table subscript object into actual subscripts,
 248 
                % take note of a colon object. The concrete dim class may have
 249 
                % already translated some kinds of subscript objects that need
 250 
                % dim-specific infomration to do the translation.
  0.011 
 225460 
 251
                isColonObj = false; 
  0.014 
 225460 
 252
                if isobject(subscripts) 
 253 
                    if isa(subscripts,'matlab.internal.tabular.private.subscripter')
 254 
                        subscripts = subscripts.getSubscripts(obj);
 255 
                    end
 256 
                    % The subscript may be a colonobj, or a timerange subscripter may return one.
 257 
                    if isa(subscripts,'matlab.internal.ColonDescriptor')
 258 
                        isColonObj = true;
 259 
                    end
  0.013 
 225460 
 260
                end 
 261 
                
  0.016 
 225460 
 262
                if isnumeric(subscripts) || islogical(subscripts) || isColonObj 
  0.006 
 149697 
 263
                    isLiteralColon = false; 
  0.006 
 149697 
 264
                    isLabels = false; 
 265 
                    
 266 
                    % Leave numeric and logical indices alone.
  0.008 
 149697 
 267
                    if isnumeric(subscripts) 
  0.004 
  80397 
 268
                        indices = subscripts(:); 
  0.005 
  80397 
 269
                        if any(isnan(indices)) 
 270 
                            error(message('MATLAB:badsubscript',getString(message('MATLAB:badsubscriptTextRange'))));
  0.003 
  80397 
 271
                        end 
  0.004 
  80397 
 272
                        numIndices = numel(indices); 
  0.004 
  80397 
 273
                        maxIndex = max(indices); 
  0.004 
  69300 
 274
                    elseif islogical(subscripts) 
  0.021 
  69300 
 275
                        indices = subscripts(:); 
  0.027 
  69300 
 276
                        numIndices = sum(indices); 
  0.113 
  69300 
 277
                        maxIndex = find(indices,1,'last'); 
 278 
                    else % isColonObj
 279 
                        indices = subscripts; % unexpanded
 280 
                        numIndices = length(subscripts); %#ok<CPROPLC>
 281 
                        maxIndex = double(subscripts.Stop);
  0.007 
 149697 
 282
                    end 
 283 
                    
  0.117 
 149697 
 284
                    subsTypes = obj.subsType; 
  0.006 
 149697 
 285
                    switch subsType 
  0.021 
 149697 
 286
                    case subsTypes.reference 
  0.023 
 146328 
 287
                        if maxIndex > obj.length 
 288 
                            obj.throwIndexOutOfRange();
  0.009 
 146328 
 289
                        elseif nargout > 4 
  2.331 
 108859 
 290
                            updatedObj = obj.selectFrom(indices); 
  0.006 
 146328 
 291
                        end 
< 0.001 
   3369 
 292
                    case subsTypes.assignment 
< 0.001 
   3369 
 293
                        if nargout > 4 
< 0.001 
   3369 
 294
                            if maxIndex > obj.length 
 295 
                                % Grow the dimension with default labels.
 296 
                                updatedObj = obj.lengthenTo(maxIndex);
< 0.001 
   3369 
 297
                            else 
< 0.001 
   3369 
 298
                                updatedObj = obj; 
< 0.001 
   3369 
 299
                            end 
< 0.001 
   3369 
 300
                        end 
 301 
                    case subsTypes.deletion
 302 
                        if maxIndex > obj.length
 303 
                            obj.throwIndexOutOfRange();
 304 
                        elseif nargout > 4
 305 
                            updatedObj = obj.deleteFrom(indices);
 306 
                        end
 307 
                    otherwise
 308 
                        assert(false);
  0.007 
 149697 
 309
                    end 
 310 
                    
  0.175 
  75763 
 311
                elseif isColon(subscripts) 
 312 
                    % Leave ':' alone. The : is evaluated with respect to the existing
 313 
                    % dimension. Cases where : needs to be evaluated with respect to the
 314 
                    % RHS of an assignment (i.e. assigning to a 0x0) need to be handled
 315 
                    % elsewhere.
  0.003 
  70095 
 316
                    isLiteralColon = true; 
  0.003 
  70095 
 317
                    isLabels = false; 
  0.003 
  70095 
 318
                    indices = subscripts; 
  0.009 
  70095 
 319
                    numIndices = obj.length; 
  0.008 
  70095 
 320
                    maxIndex = obj.length; 
 321 
                    
  0.004 
  70095 
 322
                    if nargout > 4 
  0.004 
  70088 
 323
                        updatedObj = obj; 
  0.003 
  70095 
 324
                    end 
 325 
                    
< 0.001 
   5668 
 326
                else % "native" subscripts, i.e. names or times 
< 0.001 
   5668 
 327
                    isLiteralColon = false; 
< 0.001 
   5668 
 328
                    isLabels = true; 
 329 
                    
 330 
                    % Translate labels into indices.
  0.174 
   5668 
 331
                    [subscripts,indices] = obj.validateNativeSubscripts(subscripts); 
< 0.001 
   5668 
 332
                    numIndices = numel(indices); 
< 0.001 
   5668 
 333
                    maxIndex = max(indices(:)); 
 334 
                    
  0.005 
   5668 
 335
                    subsTypes = obj.subsType; 
< 0.001 
   5668 
 336
                    switch subsType 
  0.001 
   5668 
 337
                    case subsTypes.reference 
  0.006 
   5668 
 338
                        if nnz(indices) < numIndices 
 339 
                            if obj.requireUniqueLabels
 340 
                                newLabels = unique(subscripts(~indices),'stable');
 341 
                                obj.throwUnrecognizedLabel(newLabels(1));
 342 
                            end
 343 
                            indices = indices(indices>0);
< 0.001 
   5668 
 344
                        end 
< 0.001 
   5668 
 345
                        if nargout > 4 
 346 
                            updatedObj = obj.selectFrom(indices);
< 0.001 
   5668 
 347
                        end 
 348 
                    case subsTypes.assignment
 349 
                        if nnz(indices) < numIndices
 350 
                            [newLabels,~,newIndices] = unique(subscripts(~indices),'stable');
 351 
                            indices(~indices) = obj.length + newIndices;
 352 
                            maxIndex = max(indices(:));
 353 
                            if nargout > 4
 354 
                                % The new labels are guaranteed be distinct from the existing
 355 
                                % labels, otherwise the assignment would not need to
 356 
                                % lengthen the dimension.
 357 
                                updatedObj = obj.lengthenTo(maxIndex,newLabels);
 358 
                            end
 359 
                        elseif nargout > 4
 360 
                            updatedObj = obj;
 361 
                        end
 362 
                    case subsTypes.deletion
 363 
                        if nnz(indices) < numIndices
 364 
                            newLabels = unique(subscripts(~indices),'stable');
 365 
                            obj.throwUnrecognizedLabel(newLabels(1));
 366 
                        elseif nargout > 4
 367 
                            updatedObj = obj.deleteFrom(indices);
 368 
                        end
 369 
                    otherwise
 370 
                        assert(false);
< 0.001 
   5668 
 371
                    end 
  0.010 
 225460 
 372
                end 
  0.014 
 225460 
 373
                if ~isColonObj 
  0.580 
 225460 
 374
                    indices = obj.orientAs(indices);                 
  0.027 
 225460 
 375
                end 
 376 
            catch ME
 377 
                throwAsCaller(ME)
  0.010 
 225460 
 378
            end 
  0.226 
 225460 
 379
        end 

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