This is a static copy of a profile report

Home

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

Parents (calling functions)

Function NameFunction TypeCalls
...rtOptionsSpreadsheet.getOptsFromSheetclass method2
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
60
dominantType = mode(typeIDs((m...
20.004 s32.5%
68
isBlankOrText = isStrings|ismi...
20.003 s23.3%
81
types = typenames(getDominantT...
20.002 s13.6%
58
typeIDs(typeIDs == enum.BLANK ...
20.001 s4.8%
27
emptyTrailing = find(~all(type...
20.000 s3.7%
All other lines  0.003 s22.0%
Totals  0.012 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
modefunction20.003 s28.1%
ismissingfunction20.003 s20.7%
detectTypes>getDominantTypesubfunction20.001 s9.4%
Self time (built-ins, overhead, etc.)  0.005 s41.8%
Totals  0.012 s100% 
Code Analyzer results
No Code Analyzer messages.
Coverage results
Show coverage for parent directory
Total lines in function82
Non-code lines (comments, blank lines)30
Code lines (lines that can run)52
Code lines that did run34
Code lines that did not run18
Coverage (did run/can run)65.38 %
Function listing
time 
Calls 
 line
   1 
function [types,metaRows,emptyTrailing] = detectTypes(typeIDs,emptyColumnType,metaRows,readVarNames)
   2 
%
   3 

   4 
% Copyright 2016-2019 The MathWorks, Inc.
< 0.001 
      2 
   5
    persistent enum 
< 0.001 
      2 
   6
    persistent typenames 
   7 
    
< 0.001 
      2 
   8
    if isempty(typenames) 
   9 
        enum.NUMBER = matlab.io.spreadsheet.internal.Sheet.NUMBER;
  10 
        enum.STRING = matlab.io.spreadsheet.internal.Sheet.STRING;
  11 
        enum.DATETIME = matlab.io.spreadsheet.internal.Sheet.DATETIME;
  12 
        enum.BOOLEAN = matlab.io.spreadsheet.internal.Sheet.BOOLEAN;
  13 
        enum.EMPTY = matlab.io.spreadsheet.internal.Sheet.EMPTY;
  14 
        enum.BLANK = matlab.io.spreadsheet.internal.Sheet.BLANK;
  15 
        enum.ERROR = matlab.io.spreadsheet.internal.Sheet.ERROR;
  16 
        % enum.DURATION = matlab.io.spreadsheet.internal.Sheet.DURATION;
  17 
        % these names are in the same position as the enum number value, the ''
  18 
        % values correspond to empty, blank and error.
  19 
        typenames = {'double','char','datetime','logical','','','','duration','hexadecimal','binary'};
< 0.001 
      2 
  20
    end 
  21 
    
< 0.001 
      2 
  22
    if ~exist('readVarNames','var') 
  23 
        readVarNames = true;
< 0.001 
      2 
  24
    end 
  25 
    
  26 
    % Find the trailing columns which do not contain data.
< 0.001 
      2 
  27
    emptyTrailing = find(~all(typeIDs==enum.EMPTY|typeIDs==enum.BLANK,1),1,'last')+1; 
  28 
    
< 0.001 
      2 
  29
    if ~isempty(emptyColumnType) && strcmp(emptyColumnType,'double') 
< 0.001 
      2 
  30
        EMPTY_TYPE = enum.NUMBER; 
  31 
    else
  32 
        EMPTY_TYPE = enum.STRING;
< 0.001 
      2 
  33
    end 
  34 
    
< 0.001 
      2 
  35
    if nargin <= 2 || isempty(metaRows) 
< 0.001 
      2 
  36
        textmask = (typeIDs == enum.STRING)|... 
      2 
  37
            (typeIDs == enum.BLANK)|... 
      2 
  38
            (typeIDs == enum.ERROR)|... 
      2 
  39
            (typeIDs == enum.EMPTY); 
  40 
        
  41 
        % Find the first row that doesn't contain all strings/blanks/errors
< 0.001 
      2 
  42
        metaRows = min([size(typeIDs,1),find(~all(textmask,2),1)-1]); 
  43 
        
  44 
        % If all data are string, do not detect metadata rows aside from
  45 
        % variable names
< 0.001 
      2 
  46
        if metaRows == size(typeIDs,1) 
  47 
            % always include varname line unless readVarNames is false
  48 
            metaRows = min(size(typeIDs,1),double(readVarNames));
  49 
            
  50 
            types = typenames(getDominantType(typeIDs,EMPTY_TYPE,metaRows,enum));
  51 
            return
< 0.001 
      2 
  52
        end 
< 0.001 
      2 
  53
    end 
  54 
    
  55 
    % Convert to double to add NaNs to take advantage of MODE ignoring NaN
< 0.001 
      2 
  56
    typeIDs = double(typeIDs); 
  57 
    % Ignore all these
< 0.001 
      2 
  58
    typeIDs(typeIDs == enum.BLANK | typeIDs == enum.ERROR | typeIDs == enum.EMPTY) = NaN; 
  59 
    % Compute the dominant type of all rows excluding metaRows
  0.004 
      2 
  60
    dominantType = mode(typeIDs((metaRows+1):end,:),1); 
  61 
    
< 0.001 
      2 
  62
    if any(dominantType ~= enum.STRING) && (metaRows > 0) 
  63 
        % Check each row
< 0.001 
      2 
  64
        isStrings = (dominantType == enum.STRING); 
  65 
        % not everything is string, otherwise detection returns early.
< 0.001 
      2 
  66
        for i = 1:metaRows 
< 0.001 
      2 
  67
            rowTypes = typeIDs(i,:); 
  0.003 
      2 
  68
            isBlankOrText = isStrings|ismissing(rowTypes); 
< 0.001 
      2 
  69
            if ~all(isBlankOrText) ... % blank rows don't matter 
      2 
  70
            && all(isBlankOrText | (rowTypes == dominantType) ) 
  71 
                metaRows = i-1;
  72 
                break;
< 0.001 
      2 
  73
            end 
< 0.001 
      2 
  74
        end 
  75 
    elseif all(dominantType == enum.STRING) && (metaRows > 0)
  76 
        % If all columns had String dominantType, the only metadata that
  77 
        % can be detected are variable names
  78 
        metaRows = min(size(typeIDs,1),double(readVarNames));
< 0.001 
      2 
  79
    end 
  80 
    
  0.002 
      2 
  81
    types = typenames(getDominantType(typeIDs,EMPTY_TYPE,metaRows,enum)); 
< 0.001 
      2 
  82
end 

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