This is a static copy of a profile report

Home

expandLegendChildren (Calls: 62, Time: 0.058 s)
Generated 16-Jul-2020 17:08:52 using performance time.
function in file /Applications/MATLAB_R2020a.app/toolbox/matlab/graphics/illustration/+matlab/+graphics/+illustration/+internal/expandLegendChildren.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
getLegendableChildrenfunction8
Legend.autoUpdateCallback>processGroupssubfunction54
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
18
if any(arrayfun(@(x) isa(x,'ma...
620.043 s74.5%
14
legKidsOut = matlab.graphics.p...
620.013 s23.0%
9
if isempty(legKids)
620.000 s0.8%
42
legKidsOut = legKids;
620.000 s0.5%
43
end
620.000 s0.1%
All other lines  0.001 s1.1%
Totals  0.058 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
...(x,'matlab.graphics.primitive.Group')anonymous function4340.009 s15.2%
Self time (built-ins, overhead, etc.)  0.049 s84.8%
Totals  0.058 s100% 
Code Analyzer results
Line numberMessage
26The variable 'legKidsOut' appears to change size on every loop iteration. Consider preallocating for speed.
29The variable 'legKidsOut' appears to change size on every loop iteration. Consider preallocating for speed.
32The variable 'legKidsOut' appears to change size on every loop iteration. Consider preallocating for speed.
35The variable 'legKidsOut' appears to change size on every loop iteration. Consider preallocating for speed.
Coverage results
Show coverage for parent directory
Total lines in function43
Non-code lines (comments, blank lines)14
Code lines (lines that can run)29
Code lines that did run8
Code lines that did not run21
Coverage (did run/can run)27.59 %
Function listing
time 
Calls 
 line
   1 
function legKidsOut = expandLegendChildren(legKids)
   2 
%EXPANDLEGENDCHILDREN recursively goes through a list of graphics objects,
   3 
%   expanding groups whose "LegendEntry" display property is set to
   4 
%   "Children".
   5 

   6 
%   Copyright 2007-2014 The MathWorks, Inc.
   7 

< 0.001 
     62 
   8
legKidsOut = []; 
< 0.001 
     62 
   9
if isempty(legKids) 
  10 
    return
< 0.001 
     62 
  11
end 
  12 

  13 
% Legend PlotChildren property expects objects of class primitive.Data
  0.013 
     62 
  14
legKidsOut = matlab.graphics.primitive.Data.empty; 
  15 

  16 
% only do the recurisve expanson (which is slow) if there is an hggroup
  17 
% present
  0.043 
     62 
  18
if any(arrayfun(@(x) isa(x,'matlab.graphics.primitive.Group'),legKids))  
  19 
    for i = 1:length(legKids)
  20 
        hA = get(legKids(i),'Annotation');
  21 
        if isobject(hA) && isvalid(hA)
  22 
            hL = get(hA,'LegendInformation');
  23 
            if isobject(hA) && isvalid(hA) && strcmpi(hL.IconDisplayStyle,'Children')
  24 
                if isprop(handle(legKids(i)),'Children') && ...
  25 
                        ~isempty(get(legKids(i),'Children'))
  26 
                    legKidsOut = [legKidsOut;...
  27 
                        matlab.graphics.illustration.internal.expandLegendChildren(get(legKids(i),'Children'))];
  28 
                else
  29 
                    legKidsOut = [legKidsOut;legKids(i)];
  30 
                end
  31 
            else
  32 
                legKidsOut = [legKidsOut;legKids(i)];
  33 
            end
  34 
        else
  35 
            legKidsOut = [legKidsOut;legKids(i)];
  36 
        end
  37 
    end
  38 
    % make sure we haven't pulledin any non-legendable Group children
  39 
    legKidsOut = legKidsOut(matlab.graphics.illustration.internal.islegendable(legKidsOut));
< 0.001 
     62 
  40
else 
  41 
    % if there are no groups just return the input array
< 0.001 
     62 
  42
    legKidsOut = legKids; 
< 0.001 
     62 
  43
end