This is a static copy of a profile report

Home

graphics/private/render (40 calls, 21.805 sec)
Generated 05-Aug-2011 13:03:30 using cpu time.
function in file /usr/local/MATLAB/R2011a/toolbox/matlab/graphics/private/render.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
print>LocalPrintsubfunction40
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
142
pj.Return = hardcopy( inputarg...
4020.068 s92.0%
193
imwrite( pj.Return, pj.FileNam...
401.650 s7.6%
179
imwriteArgs = LocalCreateImwri...
400.055 s0.3%
131
inputargs = LocalPrintJob2Argu...
400.022 s0.1%
190
elseif strcmp('rotated', getge...
400.011 s0.1%
All other lines  0 s0%
Totals  21.805 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
hardcopyfunction4020.057 s92.0%
imwritefunction401.640 s7.5%
...private/render>LocalCreateImwriteArgssubfunction400.055 s0.3%
...rivate/render>LocalPrintJob2Argumentssubfunction400.022 s0.1%
graphics/private/getgetfunction800.011 s0.1%
graphics/...te/render>LocalGetSLSFObjectsubfunction400 s0%
graphics/private/useOriginalHGPrintingfunction400 s0%
Self time (built-ins, overhead, etc.)  0.022 s0.1%
Totals  21.805 s100% 
Code Analyzer results
Line numberMessage
123An M-Lint message was once suppressed here, but the message is no longer generated.
163An M-Lint message was once suppressed here, but the message is no longer generated.
183{ A{I} } can usually be replaced by A(I) or A(I)', which can be much faster.
183{ A{I} } can usually be replaced by A(I) or A(I)', which can be much faster.
Coverage results
[ Show coverage for parent directory ]
Total lines in function202
Non-code lines (comments, blank lines)84
Code lines (lines that can run)118
Code lines that did run35
Code lines that did not run83
Coverage (did run/can run)29.66 %
Function listing
   time   calls  line
1 function pj = render( pj, h )
2 %RENDER Method to draw a model or Figure on current page of a print job.
3 % Figure or model is drawn in the output format specified by the device
4 % option to PRINT. The Figure or model may be modified as required for
5 % printing.
6 %
7 % Ex:
8 % pj = RENDER( pj, h ); %draw Figure/model h on output of PrintJob pj
9 %
10 % See also PRINT, PREPARE.
11
12 % Copyright 1984-2010 The MathWorks, Inc.
13
40 14 error( nargchk(2,2,nargin) )
15
40 16 if (~useOriginalHGPrinting())
17 error('MATLAB:Print:ObsoleteFunction', 'The function %s should only be called when original HG printing is enabled.', upper(mfilename));
18 end
19
20 % Verify h is not empty
40 21 if isempty(h)
22 error( 'MATLAB:render:emptyHandle','Empty handle, Need a handle to a Figure or model.' )
23 end
24
25 % h could be a vector when printing with frames on old pipeline i.e. two
26 % handles, 1 for the object and 1 for the frame
40 27 for k = 1:length(h)
40 28 if(~ishandle(h(k)))
29 error( 'MATLAB:render:invalidHandle','Invalid handle, Need a valid handle to a Figure or model.');
30 end
40 31 end
32
40 33 if ~pj.Active
34 error('MATLAB:render:inactivePrintJob','PrintJob is not active')
35 end
36
40 37 pj.Error = 0; %So caller knows there was an error
40 38 pj.Exception = [];
39
40 %Call different function if using the new pipeline
40 41 [IsSLorSF, obj] = LocalGetSLSFObject(h, pj);
42
43 % Significance of the "pj.Verbose" flag (as explained by Dennis Wilkinson):
44 % pj.Verbose: That's the magic "display the Windows print dialog" switch
45 % on print (i.e. print -v), and, IIRC, is only an issue if we're
46 % invoked from a command line. We end up coming through here twice:
47 % first with pj.Verbose=1, where we go down the old path, display the
48 % dialog, then call back in with pj.Verbose=0 and go down the new path.
40 49 if ( IsSLorSF && ~logical(pj.Verbose))
50
51 %if (logical(pj.TiledPrint) || strcmp(LocalSLSFGet(obj,'PaperPositionMode'),'tiled')))
52
53 if strcmp(LocalSLSFGet(obj,'PaperOrientation'),'rotated') && ...
54 (logical(pj.TiledPrint) || strcmp(LocalSLSFGet(obj,'PaperPositionMode'),'tiled'))
55 warning('slprint:TiledRotatedPrint','Ignoring rotation in tiled mode, using landscape instead');
56 LocalSLSFSet(obj,'PaperOrientation','landscape');
57 rotatePaperOrientation = true;
58 else
59 rotatePaperOrientation = false;
60 end
61
62 pj = LocalRender(pj, obj);
63
64 if rotatePaperOrientation
65 LocalSLSFSet(obj,'PaperOrientation','rotated');
66 end
67
68 return;
69 %end
70
71 end % if (IsSLorSF)
72
73 %Call the output driver and render Figure/model to device, file, or
74 %clipboard. We report error in PrintJob flag, caller will error out (allows
75 %it to recover gracefully).
40 76 try
77
78 %If writing out to PS for later conversion via GS to an image format,
79 %true for either Simulink TIFF previews or for saving in pgm type formats,
80 %must move the objects to the lower-left of the page so we can crop the image.
40 81 if pj.GhostImage
82 %Save all the current values of the 'paper' properties
83 %Then move each object(s) PaperPosition to lower left
84 %using points; saved a translation for every object on
85 %the current page earlier.
86 pp = cell(size(h));
87 for i = 1:length(h)
88 pp{i} = getpp(h(i));
89 setset( h(i), 'paperunits', 'points' )
90 if ~strcmp(pj.GhostDriver, 'pdfwrite')
91 % Change the paperposition if the output format is not
92 % PDF, since PDF is a format that supports margins
93 setset( h(i), 'paperposition', getget(h(i), ...
94 'paperposition')-[pj.GhostTranslation 0 0] )
95
96 end
97
98 end
99 end
100
101 %Create TIFF preview file
40 102 tiffName = '';
40 103 if pj.PostScriptPreview == pj.TiffPreview
104 %Write out TIFF temp file for concatenating with EPS file later.
105 eventualName = pj.FileName;
106 pj.FileName = [tempname '.eps'];
107
108 try
109 tiffName = LocalWriteTiff( pj, h );
110 wasErr = 0;
111 catch ex
112 wasErr = 1;
113 end
114
115 %Restore paper properties if using GS to create TIFF
116 if pj.GhostImage
117 for i = 1:length(h)
118 setpp( h(i), pp{i} )
119 end
120 end
121
122 if wasErr
123 rethrow(ex); %#ok
124 end
125
126 %Using GS only to create TIFF for SL, don't want to call it again later.
127 pj.GhostDriver = '';
128 end
129
130 %Make argument cell array for calling HARDCOPY
0.02 40 131 inputargs = LocalPrintJob2Arguments( pj, h );
132
40 133 if pj.DebugMode
134 fprintf('Printing handle: %d\n', inputargs{1})
135 fprintf('Passing input args to hardcopy: ')
136 fprintf('''%s'' ', inputargs{2:end})
137 fprintf('\n')
138 end
139
140 %Create the output file
40 141 try
20.07 40 142 pj.Return = hardcopy( inputargs{:} );
40 143 wasErr = 0;
144 catch ex
145 wasErr = 1;
146 end
147
148 %Restore paper properties now if using GS to create image output.
40 149 if logical(pj.GhostImage) && (pj.PostScriptPreview ~= pj.TiffPreview)
150 for i = 1:length(h)
151 setpp( h(i), pp{i} )
152 end
153 end
154
155 %If we had a problem with creating the EPS file, clean up
156 %before erroring out.
40 157 if wasErr
158 if ~pj.DebugMode
159 if exist(pj.FileName,'file'), delete(pj.FileName); end
160 if exist(pj.GhostName,'file'), delete(pj.GhostName); end
161 if exist(tiffName,'file'), delete(tiffName); end
162 end
163 rethrow(ex) %#ok
164 end
165
40 166 if (pj.PostScriptPreview == pj.TiffPreview) && ~isempty( tiffName )
167 catpreview( pj, pj.FileName, tiffName, eventualName );
168 pj.FileName = eventualName; %just in case
169 end
170
171 %Some output formats are generated by first creating ZBuffer via hardcopy
172 %then using IMWRITE to output the image. The default extension of the specified
173 %format is passed to IMWRITE in case user gave FileName a different ext.
40 174 if strcmp( pj.DriverClass, 'IM')
40 175 dims = size(pj.Return);
40 176 if length(dims) ~=3 || dims(3) ~= 3
177 error('MATLAB:render:badData','Bad data returned by HARDCOPY. Not calling IMWRITE.')
40 178 else
0.05 40 179 imwriteArgs = LocalCreateImwriteArgs( pj );
180
40 181 if pj.DebugMode
182 fprintf('Passing input args to IMWRITE: ')
183 sArgs = cell2struct({imwriteArgs{2:2:end}}, {imwriteArgs{1:2:end}}, 2);
184 disp(sArgs);
185 fprintf('\n')
186 end
187
40 188 if strcmp('landscape', getget(h,'paperorientation') )
189 pj.Return = cat( 3, rot90(pj.Return(:,:,1),1), rot90(pj.Return(:,:,2),1), rot90(pj.Return(:,:,3),1) );
0.01 40 190 elseif strcmp('rotated', getget(h,'paperorientation') )
191 pj.Return = cat( 3, rot90(pj.Return(:,:,1),-1), rot90(pj.Return(:,:,2),-1), rot90(pj.Return(:,:,3),-1) );
192 end
1.65 40 193 imwrite( pj.Return, pj.FileName, pj.DriverExt, imwriteArgs{:} );
40 194 pj.Return = 0;
40 195 end
196
40 197 end
198
199 catch ex
200 pj.Error = 1;
201 pj.Exception = ex;
202 end

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