This is a static copy of a profile report

Home

readSpreadsheetVariable>readTextSpreadsheetVariable (Calls: 8, Time: 0.014 s)
Generated 04-Jun-2021 04:11:14 using performance time.
subfunction in file C:\Program Files\MATLAB\R2020b\toolbox\matlab\io\spreadsheet\+matlab\+io\+spreadsheet\+internal\readSpreadsheetVariable.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
readSpreadsheetVariablefunction8
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
89
varopts = getOptsStruct(varopt...
50.004 s30.9%
80
var = repmat({''},size(typeIDs...
80.002 s17.2%
94
data = sheet.readStrings(subra...
80.001 s7.4%
99
[textData, errData, placeholde...
170.001 s6.4%
84
errid = false(size(typeIDs));
80.001 s4.2%
All other lines  0.005 s34.0%
Totals  0.014 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
...xtVariableImportOptions.getOptsStructclass method50.004 s28.0%
repmatfunction80.002 s11.5%
VarOptsInputs>VarOptsInputs.get.Typeclass method50.000 s1.1%
Self time (built-ins, overhead, etc.)  0.008 s59.4%
Totals  0.014 s100% 
Code Analyzer results
No Code Analyzer messages.
Coverage results
Show coverage for parent directory
Total lines in function57
Non-code lines (comments, blank lines)14
Code lines (lines that can run)43
Code lines that did run30
Code lines that did not run13
Coverage (did run/can run)69.77 %
Function listing
time 
Calls 
 line
  75 
function [var,errid,placeholder] = readTextSpreadsheetVariable(varopts,sheet,subrange,typeIDs)
  76 
% Construct a placeholder var based on datatype - string or char
< 0.001 
      8 
  77
if strcmp(varopts.Type, 'string') 
  78 
    var = strings(size(typeIDs));
< 0.001 
      8 
  79
else 
  0.002 
      8 
  80
    var = repmat({''},size(typeIDs)); 
< 0.001 
      8 
  81
end 
  82 

  83 
% Initialize errid + placeholder logical vector
< 0.001 
      8 
  84
errid = false(size(typeIDs)); 
< 0.001 
      8 
  85
placeholder = errid; 
  86 

  87 
% If varopts is not a struct, convert to a struct
< 0.001 
      8 
  88
if ~(isstruct(varopts)) 
  0.004 
      5 
  89
    varopts = getOptsStruct(varopts); 
< 0.001 
      8 
  90
end 
  91 

< 0.001 
      8 
  92
textmask = typeIDs == sheet.STRING; 
< 0.001 
      8 
  93
if any(textmask,'all') 
  0.001 
      8 
  94
    data = sheet.readStrings(subrange); 
  95 
    
  96 
    % Operate columnwise
< 0.001 
      8 
  97
    for i = 1:size(data,2) 
< 0.001 
     17 
  98
        textmaskInd = textmask(:,i); 
< 0.001 
     17 
  99
        [textData, errData, placeholdermask] = matlab.io.internal.text.datatypeConvertFromString(varopts,data(textmaskInd,i)); 
 100 
        
< 0.001 
     17 
 101
        placeholder(textmaskInd,i) = placeholdermask; 
< 0.001 
     17 
 102
        errid(textmaskInd,i) = errData; 
< 0.001 
     17 
 103
        var(textmaskInd,i) = textData; 
< 0.001 
     17 
 104
    end 
 105 
else
 106 
    placeholder = false(size(typeIDs));
< 0.001 
      8 
 107
end 
 108 

< 0.001 
      8 
 109
datemask = typeIDs == sheet.DATETIME; 
< 0.001 
      8 
 110
if any(datemask,'all') 
 111 
    complexRepDates = sheet.readDates(subrange);
 112 
    dates = matlab.io.spreadsheet.internal.createDatetime(complexRepDates(datemask), 'default', '');
 113 
    var(datemask) = cellstr(dates, [], 'system');
< 0.001 
      8 
 114
end 
 115 

< 0.001 
      8 
 116
boolmask = typeIDs == sheet.BOOLEAN; 
< 0.001 
      8 
 117
if any(boolmask,'all') 
 118 
    % Convert to 'true' and 'false'
 119 
    values = {'true'; 'false'};
 120 
    data = sheet.readBooleans(subrange);
 121 
    var(boolmask) = values(2 - data(boolmask),:);
< 0.001 
      8 
 122
end 
 123 

< 0.001 
      8 
 124
numbermask = typeIDs == sheet.NUMBER; 
< 0.001 
      8 
 125
if any(numbermask,'all') 
 126 
    data = sheet.readNumbers(subrange);
 127 
    data(~numbermask) = [];
 128 
    strdata = num2str(data(:));
 129 
    var(numbermask) = strtrim(cellstr(strdata));
< 0.001 
      8 
 130
end 
< 0.001 
      8 
 131
end 

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