This is a static copy of a profile report

Home

Function details for PublishFigures>PublishFigures.leavingCellThis is a static copy of a profile report

Home

PublishFigures>PublishFigures.leavingCell (Calls: 5, Time: 0.086 s)
Generated 28-Jun-2020 10:10:21 using performance time.
class method in file /Applications/MATLAB_R2018a.app/toolbox/matlab/codetools/+internal/+matlab/+publish/PublishFigures.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
snapnow>leavingCellsubfunction5
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
72
missingFigures = setdiff(figur...
50.031 s36.7%
68
figuresToSnap = internal.matla...
50.015 s17.1%
67
newFigures = internal.matlab.p...
50.011 s13.2%
64
figuresOriginal = allchild(0);
50.009 s10.1%
73
isSnapped = ismember(figuresOr...
50.009 s10.0%
All other lines  0.011 s13.0%
Totals  0.086 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
setdifffunction50.031 s35.8%
captureFiguresfunction100.018 s21.2%
compareFiguresfunction50.014 s16.3%
ismemberfunction50.008 s9.7%
allchildfunction50.008 s9.6%
flipudfunction50.000 s0.4%
Self time (built-ins, overhead, etc.)  0.006 s7.0%
Totals  0.086 s100% 
Code Analyzer results
Line numberMessage
134To pass MException properties to the warning function, use a format specifier. For example, warning(E.identifier, '%s', E.message).
Coverage results
Show coverage for parent directory
Total lines in function79
Non-code lines (comments, blank lines)35
Code lines (lines that can run)44
Code lines that did run15
Code lines that did not run29
Coverage (did run/can run)34.09 %
Function listing
time 
Calls 
 line
  61 
        function newFiles = leavingCell(obj,~)
  62 
            % Before doing anything else, especially DRAWNOW, get the
  63 
            % figure order.
  0.009 
      5 
  64
            figuresOriginal = allchild(0); 
  65 
          
  66 
            % Determine which figures need a snapshot.
  0.011 
      5 
  67
            newFigures = internal.matlab.publish.captureFigures; 
  0.015 
      5 
  68
            figuresToSnap = internal.matlab.publish.compareFigures(obj.savedState, newFigures); 
  69 
            
  70 
            % Use the original order, just in case they have been moved
  71 
            % about by the operating system during DRAWNOWs.
  0.031 
      5 
  72
            missingFigures = setdiff(figuresToSnap,figuresOriginal)'; 
  0.009 
      5 
  73
            isSnapped = ismember(figuresOriginal,figuresToSnap); 
< 0.001 
      5 
  74
            figuresToSnap = flipud(figuresOriginal(isSnapped)); 
< 0.001 
      5 
  75
            figuresToSnap = [figuresToSnap; missingFigures]; 
  76 
            
  77 
            % Take a snapshot of the each figure that needs it.
  78 
            % Ensure that for figures docked to a
  79 
            % matlabshared.scopes.Container, only one snapshot is taken per
  80 
            % container when leaving the cell.
< 0.001 
      5 
  81
            newFiles = cell(size(figuresToSnap)); 
< 0.001 
      5 
  82
            figContainersSnapped = cell(size(figuresToSnap)); 
< 0.001 
      5 
  83
            for figuresToSnapCount = 1:numel(figuresToSnap) 
  84 
                f = figuresToSnap(figuresToSnapCount);
  85 
                
  86 
                isDocked = strcmpi(f.WindowStyle,'docked');
  87 
                grpName = '';
  88 
                if isDocked
  89 
                    % Determine the group name
  90 
                    [lastWarnMsg,lastWarnId] = lastwarn;
  91 
                    warnstate = warning('off','MATLAB:HandleGraphics:ObsoletedProperty:JavaFrame');
  92 
                    jf = get(f, 'JavaFrame');
  93 
                    warning(warnstate); % Restore the original warning state
  94 
                    % restore the last warning thrown
  95 
                    lastwarn(lastWarnMsg, lastWarnId);
  96 
                    if ~isempty(jf)
  97 
                        grpName = char(jf.getGroupName);
  98 
                    end
  99 
                end
 100 
                % Do not snap if we have already snapped the
 101 
                % group/container to which the figure belongs.
 102 
                shouldSnap =  ~isDocked || (isDocked && ~any(strcmpi(figContainersSnapped,grpName))); 
 103 
                
 104 
                if shouldSnap
 105 
                    imgFilename = snap(obj, f);
 106 
                    if isDocked && ismember(grpName,internal.matlab.publish.PublishFigures.setgetContainerNames)
 107 
                        % Add the group/container name that was snapped
 108 
                        figContainersSnapped{figuresToSnapCount} = grpName;
 109 
                    end
 110 
                    
 111 
                     % Add to list of figures.
 112 
                     newFiles{figuresToSnapCount} = imgFilename;
 113 
                end               
 114 

 115 
            end
 116 
            
 117 
            % Remove empty filename as it will error with fileparts call to
 118 
            % determine the file extension and result in empty file
 119 
            % references.
< 0.001 
      5 
 120
            newFiles(cellfun('isempty',newFiles)) = []; 
 121 
            
 122 
            % Update SNAPNOW's view of the current state of figures.
 123 
            % Since the process of printing can change certain properties,
 124 
            % recapture figures to prevent extra snaps.
  0.008 
      5 
 125
            obj.savedState = internal.matlab.publish.captureFigures; 
 126 

 127 
            % Restore the figures to the original order, in case printing
 128 
            % or something else jostled them.
< 0.001 
      5 
 129
            try 
 130 
                % Use ishandle to ignore figures which have closed.
< 0.001 
      5 
 131
                set(0,'children',figuresOriginal(ishandle(figuresOriginal))); 
 132 
            catch e
 133 
                if strcmp(e.identifier,'MATLAB:hg:g_object:BadChildren')
 134 
                    warning(e.identifier,e.message)
 135 
                else
 136 
                    rethrow(e)
 137 
                end
 138 
            end
< 0.001 
      5 
 139
        end 

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