This is a static copy of a profile report

Home

tabular.numArgumentsFromSubscript (Calls: 175556, Time: 0.322 s)
Generated 04-Jun-2021 04:11:25 using performance time.
function in file C:\Program Files\MATLAB\R2020b\toolbox\matlab\datatypes\tabular\@tabular\numArgumentsFromSubscript.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
...hImportOptionsSpreadsheet.executeImplclass method2
script9script36234
computecostfunction135720
getrowmostcostfunction1440
getrowcostfunction720
getneighborsoffunction720
computenumberfunction720
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
112
end
1755540.030 s9.2%
11
if isscalar(s) % one level of ...
1755560.013 s4.2%
12
sz = 1; % table returns one ar...
1755540.007 s2.3%
13
elseif context == matlab.mixin...
20.000 s0.1%
15
elseif s(end).type == "()"
20.000 s0.1%
All other lines  0.271 s84.2%
Totals  0.322 s100% 
Children (called functions)
No children
Code Analyzer results
No Code Analyzer messages.
Coverage results
Show coverage for parent directory
Total lines in function112
Non-code lines (comments, blank lines)45
Code lines (lines that can run)67
Code lines that did run14
Code lines that did not run53
Coverage (did run/can run)20.90 %
Function listing
time 
Calls 
 line
   1 
function sz = numArgumentsFromSubscript(t,s,context)
   2 
%NUMARGUMENTSFROMSUBSCRIPT Number of output arguments for a table subscript.
   3 

   4 
% This function is for internal use only and will change in a
   5 
% future release.  Do not use this function.
   6 

   7 
%   Copyright 2016-2019 The MathWorks, Inc.
   8 

   9 
import matlab.internal.datatypes.isColon
  10 

  0.013 
 175556 
  11
if isscalar(s) % one level of subscripting on a table 
  0.007 
 175554 
  12
    sz = 1; % table returns one array for parens, braces, and dot 
< 0.001 
      2 
  13
elseif context == matlab.mixin.util.IndexingContext.Assignment 
  14 
    sz = 1; % table subsasgn only ever accepts one rhs value
< 0.001 
      2 
  15
elseif s(end).type == "()" 
  16 
    % This should never be called with parentheses as the last
  17 
    % subscript, but return 1 for that just in case
  18 
    sz = 1;
< 0.001 
      2 
  19
else % multiple subscripting levels 
< 0.001 
      2 
  20
    recurseAtLevel = 2; 
  21 
    % Perform one level of indexing, then forward result to builtin numArgumentsFromSubscript
< 0.001 
      2 
  22
    if s(1).type == "{}" 
  23 
        x = t.subsrefBraces(s(1));
  24 
        % Need to handle string subscripts
  25 
        if ~isequal(s(2).type,'.') % t.Var(...) or t.Var{...}
  26 
            % Dot-parens or dot-braces subscripting might use row labels inherited from the
  27 
            % table, translate those to indices.
  28 
            rowInds = s(2).subs{1};
  29 
            if isstring(rowInds)
  30 
                numericRowIndices = t.rowDim.subs2inds(rowInds); % (leaves ':' alone)
  31 
                % subs2inds returns the indices as a col vector, but subscripting on a table
  32 
                % variable (as opposed to on a table) should follow the usual reshaping rules.
  33 
                % Nothing to do for one (char) name, including ':', but preserve a cellstr
  34 
                % subscript's original shape.
  35 
                if ~isscalar(rowInds), numericRowIndices = reshape(numericRowIndices,size(rowInds)); end
  36 
                s(2).subs{1} = numericRowIndices;
  37 
            end
  38 
        end
< 0.001 
      2 
  39
    elseif s(1).type == "." 
< 0.001 
      2 
  40
        if strcmp(s(1).subs, "Properties") 
< 0.001 
      2 
  41
            if isequal(s(2).type,'.') 
< 0.001 
      2 
  42
                if length(s) == 2 % t.Properties.PropertyName 
      2 
  43
                    sz = 1; % no need to validate the name, subsref will do that 
< 0.001 
      2 
  44
                    return 
  45 
                else % t.Properties.PropertyName...
  46 
                    % Strip off _two_ levels of subscripting, this makes common cases like
  47 
                    % t.Properties.VariableNames{1} significantly faster
  48 
                    x = t.getProperty(s(2));
  49 
                    recurseAtLevel = 3;
  50 
                    % If this is 1-D parens/braces subscripting on a property, convert names to indices
  51 
                    % for properties that support named indexing, e.g.t.Properties.RowNames{'SomeName'}
  52 
                    if (s(3).type ~= ".") && isscalar(s(3).subs)
  53 
                        propertyIndices = s(3).subs{1};
  54 
                        if isnumeric(propertyIndices) || islogical(propertyIndices) || isColon(propertyIndices)
  55 
                            % Can leave these alone to save overhead of calling subs2inds
  56 
                        else % named subscripting
  57 
                            switch s(2).subs
  58 
                            case {'VariableNames' 'VariableDescriptions' 'VariableUnits'}
  59 
                                s(3).subs{1} = t.varDim.subs2inds(propertyIndices);
  60 
                            case 'RowNames'
  61 
                                s(3).subs{1} = t.rowDim.subs2inds(propertyIndices);
  62 
                            case 'DimensionNames'
  63 
                                s(3).subs{1} = t.metaDim.subs2inds(propertyIndices);
  64 
                            end
  65 
                        end
  66 
                    end
  67 
                end
  68 
            else % t.Properties(...) or t.Properties{...}
  69 
                x = t.getProperties(); % let t.Properties's numArgumentsFromSubscript throw the error
  70 
            end
  71 
        else
  72 
            % The try-catch is needed here to enable exception corrections
  73 
            % thrown in the subscripting call.
  74 
            %
  75 
            % i.e.
  76 
            %     >> t.var1{1}                    => t.Var1{1}
  77 
            %     >> t.properties.DimensionNames  => t.Properties.DimensionNames
  78 
            try x = t.subsrefDot(s(1)); catch ME, throw(ME); end
  79 
            if ~isequal(s(2).type,'.') % t.Var(...) or t.Var{...}
  80 
                % Dot-parens or dot-braces subscripting might use row labels inherited from the
  81 
                % table, translate those to indices.
  82 
                rowIndices = s(2).subs{1};
  83 
                if isnumeric(rowIndices) || islogical(rowIndices) || isColon(rowIndices)
  84 
                    % Can leave these alone to save overhead of calling subs2inds
  85 
                else
  86 
                    if ~iscolumn(x) && isscalar(s(2).subs)
  87 
                        error(message('MATLAB:table:InvalidLinearIndexing'));
  88 
                    end
  89 
                    numericRowIndices = t.rowDim.subs2inds(rowIndices); % (leaves ':' alone)
  90 
                    % subs2inds returns the indices as a col vector, but subscripting on a table
  91 
                    % variable (as opposed to on a table) should follow the usual reshaping rules.
  92 
                    % Nothing to do for one (char) name, including ':', but preserve a cellstr
  93 
                    % subscript's original shape.
  94 
                    if iscell(rowIndices), numericRowIndices = reshape(numericRowIndices,size(rowIndices)); end
  95 
                    s(2).subs{1} = numericRowIndices;
  96 
                end
  97 
            else % t.Var.Field
  98 
                % OK
  99 
            end
 100 
        end
 101 
    else % strcmp(s(1).type,'()'), e.g. t(...,...).Var
 102 
        x = t.subsrefParens(s(1));
 103 
    end
 104 
    s = s(recurseAtLevel:end);
 105 
    % The try-catch is needed here to enable exception corrections thrown
 106 
    % in the subscripting call.
 107 
    %
 108 
    % i.e.
 109 
    %     >> t(:,:).var1{1}                    => t(:,:).Var1{1}
 110 
    %     >> t(:,:).properties.DimensionNames  => t(:,:).Properties.DimensionNames
 111 
    try sz = matlab.internal.tabular.private.numArgumentsFromSubscriptRecurser(x,s,context); catch ME, throw(ME); end
  0.030 
 175554 
 112
end 

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