This is a static copy of a profile report

Home

FastVarOpts>FastVarOpts.setTypes (Calls: 4, Time: 0.033 s)
Generated 04-Jun-2021 04:11:20 using performance time.
class method in file C:\Program Files\MATLAB\R2020b\toolbox\shared\io\general\+matlab\+io\+internal\FastVarOpts.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
...ns>ImportOptions.set.VariableTypesclass method2
...rtOptions>ImportOptions.setvartypeclass method2
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
78
tf = ismember(newType,t);
20.017 s51.0%
132
if ~obj.NeedsUniformCheck &...
20.012 s36.0%
133
obj.NeedsUniformCheck = true;
20.001 s1.8%
72
t = matlab.io.internal.support...
20.000 s1.2%
58
if ~exist('isHexBin','var') 
40.000 s1.1%
All other lines  0.003 s8.9%
Totals  0.033 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
ismemberfunction20.016 s49.3%
setxorfunction20.010 s31.6%
supportedTypeNamesfunction20.000 s0.4%
Self time (built-ins, overhead, etc.)  0.006 s18.8%
Totals  0.033 s100% 
Code Analyzer results
No Code Analyzer messages.
Coverage results
Show coverage for parent directory
Total lines in function81
Non-code lines (comments, blank lines)23
Code lines (lines that can run)58
Code lines that did run33
Code lines that did not run25
Coverage (did run/can run)56.90 %
Function listing
time 
Calls 
 line
  55 
        function obj = setTypes(obj,idx,newType,isHexBin)
  56 
            % Extract the property while editing, since the is a handle
  57 
            % object and validation can error based on type.
< 0.001 
      4 
  58
            if ~exist('isHexBin','var')  
< 0.001 
      4 
  59
                isHexBin = false; 
< 0.001 
      4 
  60
            end 
< 0.001 
      4 
  61
            if (isempty(idx) && isempty(newType)) 
< 0.001 
      2 
  62
                return; 
< 0.001 
      2 
  63
            end 
  64 
 
< 0.001 
      2 
  65
            newType = convertCharsToStrings(newType(:)); 
< 0.001 
      2 
  66
            if ~isstring(newType) 
  67 
                error(message('MATLAB:textio:textio:InvalidStringOrCellStringProperty','VariableTypes'));
< 0.001 
      2 
  68
            end 
  69 

< 0.001 
      2 
  70
            C = obj.OptionsStruct.Options; 
  71 

< 0.001 
      2 
  72
            t = matlab.io.internal.supportedTypeNames(); 
< 0.001 
      2 
  73
            if (isHexBin) 
  74 
                t{end + 1} = 'hexadecimal';
  75 
                t{end + 1} = 'binary';
      2 
  76
            end 
< 0.001 
      2 
  77
            t{end + 1} = 'auto'; 
  0.017 
      2 
  78
            tf = ismember(newType,t); 
< 0.001 
      2 
  79
            if ~all(tf) 
  80 
                error(message('MATLAB:textio:io:UnsupportedConversionType',newType{find(~tf,1)}));
< 0.001 
      2 
  81
            end 
  82 

< 0.001 
      2 
  83
            if isstring(newType) && isscalar(newType) 
  84 
                newType = repmat(newType, numel(idx), 1);
< 0.001 
      2 
  85
            end 
  86 
            % Don't update the types or bother checking if the new type is
  87 
            % the old type.
< 0.001 
      2 
  88
            oldTypes = obj.OptionsStruct.Types; 
< 0.001 
      2 
  89
            typeChanged = (newType ~= oldTypes(idx)); 
< 0.001 
      2 
  90
            for ii = 1:numel(idx) 
< 0.001 
      6 
  91
                kk = idx(ii); 
< 0.001 
      6 
  92
                if typeChanged(ii) 
  93 
                    % Type can change, need to validate the mismatched
  94 
                    % properties are removed.
< 0.001 
      3 
  95
                    for f = fieldnames(C{kk})' 
  96 
                        if strcmp(f,'InputFormat')
  97 
                            % datetime to duration change, this means
  98 
                            % InputFormat needs to be removed since there's
  99 
                            % no overlap between the two
 100 
                            C{kk} = rmfield(C{kk},'InputFormat');
 101 
                        elseif strcmp(f,'FillValue')
 102 
                            % Fillvalues can change when type changes,
 103 
                            % sometimes that "just works" and we can keep
 104 
                            % the old value, other times that may fail.
 105 
                            
 106 
                            if ~isCompatibleTypes(newType(ii),oldTypes(kk))
 107 
                                C{kk} = rmfield(C{kk},'FillValue');
 108 
                            end
 109 
                        else
 110 
                            if(f == "NumberSystem" && any(fieldnames(C{kk}) == "Type"))
 111 
                                C{kk}.Type= newType{ii};
 112 
                            end
 113 
                            % If the property doesn't exist on the new
 114 
                            % type, just drop it.
 115 
                            try
 116 
                                checkTypeSpecific(newType{ii},f)
 117 
                            catch
 118 
                                C{kk} = rmfield(C{kk},f);
 119 
                                if(f == "NumberSystem" && any(fieldnames(C{kk}) == "Type"))
 120 
                                    C{kk} = rmfield(C{kk},'Type');
 121 
                                end
 122 
                            end
 123 
                        end
 124 
                    end
< 0.001 
      6 
 125
                end 
< 0.001 
      6 
 126
            end 
< 0.001 
      2 
 127
            obj.OptionsStruct.Options = C; 
< 0.001 
      2 
 128
            obj.OptionsStruct.Types(idx) = cellstr(newType); 
 129 
            
 130 
            % if it was already uniform and we are setting every index
 131 
            % it's still uniform
  0.012 
      2 
 132
            if ~obj.NeedsUniformCheck && (~isempty(setxor(idx,1:numel(C))) || any(newType ~= newType(1))) 
< 0.001 
      2 
 133
                obj.NeedsUniformCheck = true; 
< 0.001 
      2 
 134
            end 
< 0.001 
      2 
 135
        end 

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