This is a static copy of a profile report

Home

categorical.categorical>categorical.castCodes (Calls: 3, Time: 0.000 s)
Generated 04-Jun-2021 04:11:26 using performance time.
class method in file C:\Program Files\MATLAB\R2020b\toolbox\matlab\datatypes\categorical\@categorical\categorical.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
...ategorical>categorical.categoricalclass method3
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
749
if numCats <= 255-1 % intma...
30.000 s46.0%
760
end
30.000 s0.5%
759
end
30.000 s0.1%
750
codes = uint8(codes);
30.000 s0.1%
All other lines  0.000 s53.2%
Totals  0.000 s100% 
Children (called functions)
No children
Code Analyzer results
No Code Analyzer messages.
Coverage results
Show coverage for parent directory
Total lines in function22
Non-code lines (comments, blank lines)10
Code lines (lines that can run)12
Code lines that did run4
Code lines that did not run8
Coverage (did run/can run)33.33 %
Function listing
time 
Calls 
 line
 739 
        function codes = castCodes(codes, numCats)
 740 
            % CASTCODES picks an integer class that is capable of encoding 'numCats' many
 741 
            % unique categories, and casts the input codes to that class.
 742 
            
 743 
            % Cast codes to the new class. This turns NaN in floating point (see e.g. min
 744 
            % and max) into a 0 integer code (i.e. <undefined>).
 745 
            %
 746 
            % Number of categories is INTMAX(class) minus one to allow for an invalid
 747 
            % code at the high end; except with UINT64, the limit is maximum array size
 748 
            % allowed in MATLAB (i.e. categorical.maxNumCategories)
< 0.001 
      3 
 749
            if numCats <= 255-1 % intmax('uint8')-1 
< 0.001 
      3 
 750
                codes = uint8(codes); 
 751 
            elseif numCats <= 65535-1 % intmax('uint16')-1
 752 
                codes = uint16(codes);
 753 
            elseif numCats <= 4294967295-1 % intmax('uint32')-1
 754 
                codes = uint32(codes);
 755 
            elseif numCats < categorical.maxNumCategories
 756 
                codes = uint64(codes);
 757 
            else % Error if exceeded maximum allowed number of categories
 758 
                throwAsCaller(message('MATLAB:categorical:MaxNumCategoriesExceeded',categorical.maxNumCategories));
< 0.001 
      3 
 759
            end 
< 0.001 
      3 
 760
        end 

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