This is a static copy of a profile report

Home

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

Parents (calling functions)

Function NameFunction TypeCalls
tabular.sortrowsfunction3
tabular.subsreffunction70592
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
44
b_data{j} = var_j(rowIndices,:...
7646332.536 s20.0%
26
[rowIndices,numRowIndices,~,is...
705952.316 s18.3%
22
b = t.cloneAsEmpty(); % respec...
705951.812 s14.3%
31
[varIndices,numVarIndices,~,~,...
705951.519 s12.0%
41
elseif isa(var_j,'tabular')
7646331.413 s11.2%
All other lines  3.060 s24.2%
Totals  12.657 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
...mension>tabularDimension.subs2indsclass method705951.950 s15.4%
table.table>table.cloneAsEmptyclass method705951.728 s13.6%
categorical.parenReferencefunction1391101.242 s9.8%
varNamesDim>varNamesDim.subs2indsclass method705951.177 s9.3%
categorical.ismatrixfunction1391100.216 s1.7%
substructfunction30.000 s0.0%
Self time (built-ins, overhead, etc.)  6.344 s50.1%
Totals  12.657 s100% 
Code Analyzer results
No Code Analyzer messages.
Coverage results
Show coverage for parent directory
Total lines in function96
Non-code lines (comments, blank lines)38
Code lines (lines that can run)58
Code lines that did run29
Code lines that did not run29
Coverage (did run/can run)50.00 %
Function listing
time 
Calls 
 line
   1 
function [b,varargout] = subsrefParens(t,s)
   2 
%SUBSREFPARENS Subscripted reference for a table.
   3 

   4 
%   Copyright 2012-2019 The MathWorks, Inc.
   5 

   6 
% '()' is a reference to a subset of a table.  If no subscripting
   7 
% follows, return the subarray.  Only dot subscripting may follow.
   8 

   9 
import matlab.internal.datatypes.isUniqueNumeric
  0.048 
  70595 
  10
subsType = matlab.internal.tabular.private.tabularDimension.subsType; 
  11 

  0.004 
  70595 
  12
if ~isstruct(s), s = substruct('()',s); end 
  13 

  0.198 
  70595 
  14
if numel(s(1).subs) ~= t.metaDim.length 
  15 
    error(message('MATLAB:table:NDSubscript'));
  0.003 
  70595 
  16
elseif isscalar(s) && nargout > 1 
  17 
    % Simple parenthesis indexing can only return a single thing.
  18 
    error(message('MATLAB:table:TooManyOutputs'));
  0.003 
  70595 
  19
end 
  20 

  21 
% Create an empty output table.
  1.812 
  70595 
  22
b = t.cloneAsEmpty(); % respect the subclass 
  23 

  24 
% Translate row labels into indices (leaves logical and ':' alone).
  0.034 
  70595 
  25
t_rowDim = t.rowDim; 
  2.316 
  70595 
  26
[rowIndices,numRowIndices,~,isColonRows,~,b_rowDim] = t_rowDim.subs2inds(s(1).subs{1},subsType.reference); 
  0.452 
  70595 
  27
b.rowDim = b_rowDim; 
  28 

  29 
% Translate variable (column) names into indices (translates logical and ':').
  0.026 
  70595 
  30
t_varDim = t.varDim; 
  1.519 
  70595 
  31
[varIndices,numVarIndices,~,~,~,b_varDim] = t_varDim.subs2inds(s(1).subs{2},subsType.reference,t.data); 
  0.595 
  70595 
  32
b.varDim = b_varDim; 
  33 

  34 
% Move the data to the output.
  0.141 
  70595 
  35
b_data = cell(1,b.varDim.length); 
  0.025 
  70595 
  36
t_data = t.data; 
  0.006 
  70595 
  37
for j = 1:numVarIndices 
  0.379 
 764633 
  38
    var_j = t_data{varIndices(j)}; 
  0.040 
 764633 
  39
    if isColonRows 
  40 
        b_data{j} = var_j; % a fast shared-data copy
  1.413 
 764633 
  41
    elseif isa(var_j,'tabular') 
  42 
        b_data{j} = var_j.subsrefParens({rowIndices ':'}); % force dispatch to overloaded table subscripting
  0.458 
 764633 
  43
    elseif ismatrix(var_j) 
  2.536 
 764633 
  44
        b_data{j} = var_j(rowIndices,:); % without using reshape, may not have one 
  45 
    else
  46 
        % Each var could have any number of dims, no way of knowing,
  47 
        % except how many rows they have.  So just treat them as 2D to get
  48 
        % the necessary rows, and then reshape to their original dims.
  49 
        sizeOut = size(var_j); sizeOut(1) = numRowIndices;
  50 
        b_data{j} = reshape(var_j(rowIndices,:), sizeOut);
  0.028 
 764633 
  51
    end 
  0.041 
 764633 
  52
end 
  0.084 
  70595 
  53
b.data = b_data; 
  54 

  55 
% Create subscripters for the output. If the RHS subscripts are labels or numeric
  56 
% indices, they may have picked out the same row or variable more than once, but
  57 
% selectFrom creates the output labels correctly.
  0.107 
  70595 
  58
b.metaDim = t.metaDim; 
  59 

  60 
% Move the per-array properties to the output.
  0.092 
  70595 
  61
b.arrayProps = t.arrayProps; 
  62 

  0.005 
  70595 
  63
if isscalar(s) 
  64 
    % If there's no additional subscripting, return the subarray.
  0.004 
  70595 
  65
    if nargout > 1 
  66 
        nargoutchk(0,1);
  0.004 
  70595 
  67
    end 
  68 
else
  69 
    switch s(2).type
  70 
    case '()'
  71 
        error(message('MATLAB:table:InvalidSubscriptExpr'));
  72 
    case '{}'
  73 
        error(message('MATLAB:table:InvalidSubscriptExpr'));
  74 
    case '.'
  75 
        % subsrefParens's output args are defined as [b,varargout] so the
  76 
        % nargout==1 case can avoid varargout, although that adds complexity to
  77 
        % the nargout==0 case. See detailed comments in subsref.
  78 
        if nargout == 1
  79 
            b = b.subsrefDot(s(2:end)); % b is a table, dispatch directly to subsrefDot
  80 
        elseif nargout > 1
  81 
            [b, varargout{1:nargout-1}] = b.subsrefDot(s(2:end));
  82 
        else % nargout == 0
  83 
            % Let varargout bump magic capture either one output or zero
  84 
            % outputs. See detailed comments in subsref.
  85 
            [varargout{1:nargout}] = b.subsrefDot(s(2:end)); % ditto
  86 
            if isempty(varargout)
  87 
                % There is nothing to return, remove the first output arg.
  88 
                clear b
  89 
            else
  90 
                % Shift the return value into the first output arg.
  91 
                b = varargout{1};
  92 
                varargout = {}; % never any additional values
  93 
            end
  94 
        end
  95 
    end
  0.194 
  70595 
  96
end 

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