This is a static copy of a profile report

Home

ReadTableWithImportOptionsSpreadsheet>ReadTableWithImportOptionsSpreadsheet.executeImpl (Calls: 2, Time: 0.150 s)
Generated 04-Jun-2021 04:11:07 using performance time.
class method in file C:\Program Files\MATLAB\R2020b\toolbox\matlab\io\spreadsheet\+matlab\+io\+internal\+functions\ReadTableWithImportOptionsSpreadsheet.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
...eadTableWithImportOptions.executeImplclass method2
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
80
rssArgs);
20.068 s45.4%
119
func.Options.PreserveVariableN...
20.056 s37.1%
121
if isempty(T.Properties.Variab...
20.008 s5.3%
120
T.Properties.VariableUnits = m...
20.004 s3.0%
82
dimNames = matlab.internal.tab...
20.003 s2.0%
All other lines  0.011 s7.3%
Totals  0.150 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
readSpreadsheetfunction20.067 s44.8%
ReadTable>ReadTable.buildTableFromDataclass method20.055 s36.4%
tabular.subsreffunction20.005 s3.4%
tabular.subsasgnfunction20.004 s2.7%
metaDim>metaDim.metaDimclass method20.002 s1.6%
tabular.numArgumentsFromSubscriptfunction20.001 s0.9%
str2doublefunction10.001 s0.4%
...gt;AcceptsSheetNameOrNumber.get.Sheetclass method20.001 s0.4%
...eadsheet>checkWrongParamsWrongTypeclass method20.001 s0.4%
...mportOptionsSpreadsheet.usingRowNamesclass method10.001 s0.4%
columnNumberfunction10.000 s0.3%
...eNamesInput.get.PreserveVariableNamesclass method20.000 s0.1%
...ns>ImportOptions.namesAreGeneratedclass method20.000 s0.1%
mustBeNumericOrLogicalfunction20.000 s0.1%
Self time (built-ins, overhead, etc.)  0.012 s7.9%
Totals  0.150 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)24
Code lines (lines that can run)72
Code lines that did run58
Code lines that did not run14
Coverage (did run/can run)80.56 %
Function listing
time 
Calls 
 line
  29 
        function [T,func] = executeImpl(func,supplied)
< 0.001 
      2 
  30
            rowNamesID = 0; rowNamesAsVariable = 0; 
  0.001 
      2 
  31
            if supplied.ReadRowNames && func.ReadRowNames && ~func.usingRowNames() 
  32 
                % User didn't define a rownamesColumn, but called readtable with ReadRowNames
  33 
                func.Options.RowNamesRange = 1;
  34 
                [rowNamesID,rowNamesAsVariable] = deselectRowNames(func);
< 0.001 
      2 
  35
            elseif supplied.ReadRowNames && ~func.ReadRowNames && func.usingRowNames() 
  36 
                % User specified a RowNamesColumn, but asked readtable not to import it.
  37 
                % set the RowNames back to default
  38 
                func.Options.RowNamesRange = '';
< 0.001 
      2 
  39
            end 
  40 
            
< 0.001 
      2 
  41
            checkWrongParamsWrongType(supplied); 
  42 
            
  0.001 
      2 
  43
            if ~supplied.ReadVariableNames ... 
      2 
  44
                    && func.Options.namesAreGenerated() ... 
      2 
  45
                    && (isnumeric(func.Options.VariableNamesRange)... 
      2 
  46
                    || func.Options.VariableNamesRange ~= "") 
< 0.001 
      2 
  47
                func.ReadVariableNames = true; 
< 0.001 
      2 
  48
                supplied.ReadVariableNames = true; 
< 0.001 
      2 
  49
            end 
  50 
            
< 0.001 
      2 
  51
            try 
< 0.001 
      2 
  52
                sheet = func.WorkSheet.SheetObj; 
< 0.001 
      2 
  53
                assert(~isempty(sheet)); 
  54 
            catch
  55 
                [S, func] = executeImplCatch(func);
  56 
                sheet = S.Sheet;
< 0.001 
      2 
  57
            end 
< 0.001 
      2 
  58
            readingRowNames = rowNamesAsVariable||~isempty(func.Options.RowNamesRange); 
< 0.001 
      2 
  59
            readingVarNames = supplied.ReadVariableNames && func.ReadVariableNames; 
  60 
            
< 0.001 
      2 
  61
            try 
< 0.001 
      2 
  62
                UseExcel = func.WorkSheet.IsComObject; 
  63 
            catch
  64 
                UseExcel = func.UseExcel;
< 0.001 
      2 
  65
            end 
  66 

< 0.001 
      2 
  67
            rssArgs = {'ReadVariableNames',readingVarNames,... 
      2 
  68
                'ReadRowNames',readingRowNames,... 
      2 
  69
                'Sheet',func.Options.Sheet,... 
      2 
  70
                'UseExcel',UseExcel,... 
  71 
                'FixVariableNames',false,...
  72 
                };
  73 
            
< 0.001 
      2 
  74
            if isfield(supplied,'TreatAsMissing') && supplied.TreatAsMissing 
  75 
                rssArgs = [rssArgs,{'TreatAsMissing',func.TreatAsMissing}];
< 0.001 
      2 
  76
            end 
  77 
            
  0.068 
      2 
  78
            [data,metadata,func.Omitted] = matlab.io.spreadsheet.internal.readSpreadsheet(... 
      2 
  79
                sheet,func.Options,... 
      2 
  80
                rssArgs); 
  81 
            
  0.003 
      2 
  82
            dimNames = matlab.internal.tabular.private.metaDim().labels; 
  83 
            
< 0.001 
      2 
  84
            if rowNamesAsVariable && rowNamesID > 0 
  85 
                % added the row names to the import variables, now take
  86 
                % it out.
  87 
                dimNames{1} = metadata.VariableNames{rowNamesID};
  88 
                metadata.VariableNames(rowNamesID) = [];
  89 
                data(rowNamesID) = [];
< 0.001 
      2 
  90
            elseif readingVarNames && readingRowNames 
  91 
                % Row Names Range was distinct from varnames, look at the
  92 
                % intersecting cell
< 0.001 
      1 
  93
                dimNamesCell(1) = string(func.Options.RowNamesRange); 
< 0.001 
      1 
  94
                dimNamesCell(2) = string(func.Options.VariableNamesRange); 
  95 
                % get the first cell, if there's more than one cell
< 0.001 
      1 
  96
                dimNamesCell(contains(dimNamesCell,':')) = extractBefore(dimNamesCell(contains(dimNamesCell,':')),':'); 
  97 
                % take the column from RowNames, and the row from
  98 
                % VariableNames and find the intersecting cell
< 0.001 
      1 
  99
                dimNamesCell(1) = regexprep(dimNamesCell(1),'\d',''); 
< 0.001 
      1 
 100
                dimNamesCell(2) = regexprep(dimNamesCell(2),'\D',''); 
< 0.001 
      1 
 101
                try  % This range might be bad, or the data might not be a name 
  0.002 
      1 
 102
                    range = [matlab.io.spreadsheet.internal.columnNumber(dimNamesCell{1}),... 
      1 
 103
                        str2double(dimNamesCell{2}),1,1]; 
< 0.001 
      1 
 104
                    d = sheet.readStrings(range); 
< 0.001 
      1 
 105
                    assert(~isempty(d{1})); 
< 0.001 
      1 
 106
                    dimNames{1} = d{1}; 
 107 
                catch
 108 
                    % Ignore failures
< 0.001 
      1 
 109
                end 
      2 
 110
            end 
 111 
            
  0.056 
      2 
 112
            T = matlab.io.internal.functions.ReadTable.buildTableFromData( ... 
      2 
 113
                data, ... 
      2 
 114
                metadata.VariableNames, ... 
      2 
 115
                metadata.RowNames, ... 
      2 
 116
                dimNames, ... 
      2 
 117
                readingVarNames, ... 
      2 
 118
                readingRowNames, ... 
      2 
 119
                func.Options.PreserveVariableNames); 
  0.004 
      2 
 120
            T.Properties.VariableUnits = metadata.VariableUnits; 
  0.008 
      2 
 121
            if isempty(T.Properties.VariableDescriptions) 
 122 
                T.Properties.VariableDescriptions = metadata.VariableDescriptions;
< 0.001 
      2 
 123
            end 
< 0.001 
      2 
 124
        end 

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