This is a static copy of a profile report

Home

FastVarOpts>getOptsStructWithDefaults (Calls: 12, Time: 0.003 s)
Generated 04-Jun-2021 04:11:24 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
FastVarOpts>FastVarOpts.getVarOptsStructclass method12
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
817
for field = fieldnames(sCustom...
120.001 s24.6%
769
if isempty(defaults)
120.000 s11.7%
783
s.Type = t;
60.000 s9.5%
787
s.FillValue = cast(s.FillValue...
60.000 s9.4%
814
s.FillValue = zeros(0);
60.000 s9.0%
All other lines  0.001 s35.8%
Totals  0.003 s100% 
Children (called functions)
No children
Code Analyzer results
No Code Analyzer messages.
Coverage results
Show coverage for parent directory
Total lines in function61
Non-code lines (comments, blank lines)10
Code lines (lines that can run)51
Code lines that did run24
Code lines that did not run27
Coverage (did run/can run)47.06 %
Function listing
time 
Calls 
 line
 766 
function s = getOptsStructWithDefaults(t,sCustom)
 767 
import matlab.io.*
< 0.001 
     12 
 768
persistent defaults 
< 0.001 
     12 
 769
if isempty(defaults) 
 770 
    defaults.numeric     = makeOptsStruct(matlab.io.NumericVariableImportOptions);
 771 
    defaults.datetime    = makeOptsStruct(matlab.io.DatetimeVariableImportOptions');
 772 
    defaults.datetime.FillValue = complex(NaN,0);
 773 
    defaults.duration    = makeOptsStruct(matlab.io.DurationVariableImportOptions');
 774 
    defaults.categorical = makeOptsStruct(matlab.io.CategoricalVariableImportOptions');
 775 
    defaults.text        = makeOptsStruct(matlab.io.TextVariableImportOptions');
 776 
    defaults.logical     = makeOptsStruct(matlab.io.LogicalVariableImportOptions');
< 0.001 
     12 
 777
end 
 778 

< 0.001 
     12 
 779
switch t 
 780 
    % FillValues should be stored in the internal format
< 0.001 
     12 
 781
    case {'uint8','uint16','uint32','uint64','int8','int16','int32','int64','double','single','auto'} 
< 0.001 
      6 
 782
        s = defaults.numeric; 
< 0.001 
      6 
 783
        s.Type = t; 
< 0.001 
      6 
 784
        if t == "auto" 
 785 
            s.FillValue = 0;
< 0.001 
      6 
 786
        else 
< 0.001 
      6 
 787
            s.FillValue = cast(s.FillValue,t); 
< 0.001 
      6 
 788
        end 
< 0.001 
      6 
 789
    case 'datetime' 
 790 
        s = defaults.datetime;
 791 
        if isfield(sCustom,'FillValue') && isdatetime(sCustom.FillValue)
 792 
            sCustom.FillValue = datetime.toMillis(sCustom.FillValue);
 793 
        end
< 0.001 
      6 
 794
    case 'duration' 
 795 
        s = defaults.duration;
 796 
        if isfield(sCustom,'FillValue') && isduration(sCustom.FillValue)
 797 
            sCustom.FillValue = milliseconds(sCustom.FillValue);
 798 
        end
< 0.001 
      6 
 799
    case 'logical' 
 800 
        s = defaults.logical;
< 0.001 
      6 
 801
    case 'categorical' 
 802 
        s = defaults.categorical;
 803 
        % Ordinal Implies Protected
 804 
        
 805 
        if isfield(sCustom,'Ordinal') && sCustom.Ordinal
 806 
            s.Protected = true;
 807 
            if isfield(sCustom, 'Protected')
 808 
                sCustom = rmfield(sCustom, 'Protected');
 809 
            end
 810 
        end
< 0.001 
      6 
 811
    case {'char','string'} 
< 0.001 
      6 
 812
        s = defaults.text; 
< 0.001 
      6 
 813
        s.Type = t; 
< 0.001 
      6 
 814
        s.FillValue = zeros(0); 
 815 

< 0.001 
     12 
 816
end 
< 0.001 
     12 
 817
for field = fieldnames(sCustom)' 
 818 
    s.(field{:}) = sCustom.(field{:});
 819 
end
 820 

 821 
% cannot create Undefined categorical value with char array '<undefined>'
< 0.001 
     12 
 822
if strcmp(t, 'categorical') && strcmp(s.FillValue, categorical.undefLabel) 
 823 
    s.FillValue = '';
< 0.001 
     12 
 824
end 
 825 

< 0.001 
     12 
 826
end 

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