This is a static copy of a profile report

Home

readSpreadsheet (Calls: 2, Time: 0.067 s)
Generated 04-Jun-2021 04:11:17 using performance time.
function in file C:\Program Files\MATLAB\R2020b\toolbox\matlab\io\spreadsheet\+matlab\+io\+spreadsheet\+internal\readSpreadsheet.m
Copy to new window for comparing multiple runs

Parents (calling functions)

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

Line NumberCodeCallsTotal Time% TimeTime Plot
27
[variables,errorIDs,missingIDs...
20.025 s37.8%
24
[~,selectedIDs] = ismember(opt...
20.014 s21.1%
72
[variables,metadata,omittedvar...
20.008 s11.2%
62
metadata.RowNames = readRowNam...
10.003 s5.1%
32
metadata.VariableNames = readV...
20.003 s4.8%
All other lines  0.013 s19.9%
Totals  0.067 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
readSpreadsheet>handleDataRangesubfunction20.025 s36.7%
cell.ismemberfunction20.012 s17.8%
readSpreadsheet>handleReplacementsubfunction20.006 s9.4%
readSpreadsheet>readRowNamessubfunction10.003 s4.6%
readSpreadsheet>readVariableMetadatasubfunction20.003 s4.3%
readSpreadsheet>parseArgumentssubfunction20.003 s4.2%
...ons>ImportOptions.getVarOptsStructclass method20.003 s3.8%
makeUniqueStringsfunction10.002 s2.2%
...portOptions.get.SelectedVariableNamesclass method20.001 s1.2%
...gt;AcceptsSheetNameOrNumber.set.Sheetclass method20.001 s1.1%
...ns>ImportOptions.get.VariableNamesclass method40.001 s0.9%
composefunction20.001 s0.9%
Self time (built-ins, overhead, etc.)  0.009 s12.8%
Totals  0.067 s100% 
Code Analyzer results
No Code Analyzer messages.
Coverage results
Show coverage for parent directory
Total lines in function73
Non-code lines (comments, blank lines)20
Code lines (lines that can run)53
Code lines that did run37
Code lines that did not run16
Coverage (did run/can run)69.81 %
Function listing
time 
Calls 
 line
   1 
function [variables,metadata,omittedvarsmap] = readSpreadsheet(filename,opts,args)
   2 
    %READSPREADSHEET reads a spreadsheet file according to the import options
   3 
    
   4 
    % Copyright 2016-2019 The MathWorks, Inc.
  0.003 
      2 
   5
    params = parseArguments(args); 
   6 

< 0.001 
      2 
   7
    if ~isempty(params.Sheet) 
  0.001 
      2 
   8
        opts.Sheet = params.Sheet; 
      2 
   9
    end 
  10 
    
< 0.001 
      2 
  11
    if ~ischar(filename) && isa(filename,'matlab.io.spreadsheet.internal.Worksheet') 
< 0.001 
      2 
  12
        sheet = filename; 
  13 
    else
  14 
        % first open the file.
  15 
        ssFile = openFile(filename,params.UseExcel);
  16 
        % then open the requested sheet
  17 
        sheet = opts.Sheet;
  18 
        if isempty(sheet)
  19 
            sheet = 1;
  20 
        end
  21 
        % get the sheet obj
  22 
        sheet = ssFile.getSheet(sheet);
< 0.001 
      2 
  23
    end 
  0.014 
      2 
  24
    [~,selectedIDs] = ismember(opts.SelectedVariableNames',opts.VariableNames); 
  25 

  26 
    % DATARANGE
  0.025 
      2 
  27
    [variables,errorIDs,missingIDs,dataRange] = handleDataRange(selectedIDs, opts, sheet, params.Preview, params.UseExcel); 
  28 
    
  29 
    % VARIABLE NAMES
< 0.001 
      2 
  30
    numVars = numel(opts.VariableNames); 
< 0.001 
      2 
  31
    if params.ReadVariableNames && ~isempty(opts.VariableNamesRange) 
  0.003 
      2 
  32
        metadata.VariableNames = readVariableMetadata(sheet,opts.VariableNamesRange,numVars); 
< 0.001 
      2 
  33
        metadata.VariableNames = metadata.VariableNames(selectedIDs); 
< 0.001 
      2 
  34
        empties = strlength(metadata.VariableNames) == 0; 
< 0.001 
      2 
  35
        metadata.VariableNames(empties) = compose('Var%d',find(empties)); 
< 0.001 
      2 
  36
        if params.FixVariableNames  
  37 
            metadata.VariableNames = matlab.lang.makeValidName(metadata.VariableNames);
  38 
            metadata.VariableNames = matlab.lang.makeUniqueStrings(metadata.VariableNames,{'RowNames','Properties'});
< 0.001 
      2 
  39
        end 
  40 
    else
  41 
        metadata.VariableNames = opts.VariableNames(selectedIDs);
< 0.001 
      2 
  42
    end 
  43 
    
  44 
    % VARIABLE UNITS 
< 0.001 
      2 
  45
    metadata.VariableUnits = {}; 
< 0.001 
      2 
  46
    if ~isempty(opts.VariableUnitsRange) 
  47 
        metadata.VariableUnits = readVariableMetadata(sheet,opts.VariableUnitsRange,numVars);
  48 
        metadata.VariableUnits = metadata.VariableUnits(selectedIDs);
< 0.001 
      2 
  49
    end 
  50 
    
  51 
    % VARIABLE DESCRIPTIONS 
< 0.001 
      2 
  52
    metadata.VariableDescriptions = {}; 
< 0.001 
      2 
  53
    if ~isempty(opts.VariableDescriptionsRange) 
  54 
        metadata.VariableDescriptions = readVariableMetadata(sheet,opts.VariableDescriptionsRange,numVars);
  55 
        metadata.VariableDescriptions = metadata.VariableDescriptions(selectedIDs);
< 0.001 
      2 
  56
    end 
  57 
    
  58 
    % ROWNAMES
< 0.001 
      2 
  59
    metadata.RowDimNames = {}; 
< 0.001 
      2 
  60
    metadata.RowNames = {}; 
< 0.001 
      2 
  61
    if ~isempty(opts.RowNamesRange) 
  0.003 
      1 
  62
        metadata.RowNames = readRowNames(sheet,opts.RowNamesRange,dataRange); 
< 0.001 
      1 
  63
        emptyNames = cellfun('isempty',metadata.RowNames); 
< 0.001 
      1 
  64
        emptyNames = emptyNames | any(params.TreatAsMissing(:)' == string(metadata.RowNames(:)),2); 
  65 
        
< 0.001 
      1 
  66
        if any(emptyNames(:)) 
  67 
            metadata.RowNames(emptyNames) = compose('Row%d',find(emptyNames));
      1 
  68
        end 
  0.002 
      1 
  69
        metadata.RowNames = matlab.lang.makeUniqueStrings(metadata.RowNames); 
< 0.001 
      2 
  70
    end 
  0.003 
      2 
  71
    varOpts = opts.getVarOptsStruct(selectedIDs); 
  0.008 
      2 
  72
    [variables,metadata,omittedvarsmap] = handleReplacement(variables,metadata,varOpts,opts.ImportErrorRule,opts.MissingRule,errorIDs,missingIDs); 
< 0.001 
      2 
  73
end 

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