HARDCOPY slower with more figures open?
8 ビュー (過去 30 日間)
古いコメントを表示
GETFRAME is slow. I'm using the HARDCOPY function as a faster alternative (it's still way too slow) in order to capture figures (with the added benefit that I don't have to worry about accidentally capturing other windows or require the Matlab or the captured window be topmost on my screen):
However, I've come across an issue that I've not seen noted anywhere related to HARDCOPY's performance when more than one figure is open. The more figures that are open the slower HARDCOPY gets. Additionally, it seems to matter which figure I capture. The slowdown can be even more severe if I capture the figure that was created first, v.s. the one that was created most recently. Here's some code to illustrate this:
close all
clear h x
h(1) = figure;
surf(peaks(100));
set(h(1),'PaperPositionMode','auto','Renderer','opengl');
x = hardcopy(h,'-dopengl','-r0');
tic
for i = 1:200
x = hardcopy(h,'-dopengl','-r0');
end
toc
close all
clear h x
h = zeros(1,20);
for i = 1:20
h(i) = figure;
surf(peaks(100));
end
set(h(20),'PaperPositionMode','auto','Renderer','opengl');
x = hardcopy(h(20),'-dopengl','-r0');
tic
for i = 1:200
x = hardcopy(h(20),'-dopengl','-r0');
end
toc
close all
clear h x
h = zeros(1,20);
for i = 1:20
h(i) = figure;
surf(peaks(100));
end
set(h(1),'PaperPositionMode','auto','Renderer','opengl');
x = hardcopy(h(1),'-dopengl','-r0');
tic
for i = 1:200
x = hardcopy(h(1),'-dopengl','-r0');
end
toc
close all
On my MacBook Pro running Mac OS X 10.6.8 and Matlab R2012a, the above returns:
Elapsed time is 3.472382 seconds.
Elapsed time is 5.997113 seconds.
Elapsed time is 12.877671 seconds.
So, when 20 identical figures are open, HARDCOPY is about 1.7 times slower to capture the most recently created figure and 3.7 times slower to capture the first. Interestingly, if the figure's Renderer property is set to 'zbuffer' and the '-dzbuffer' argument is used for HARDCOPY, the third time is about the same as the second. (EDIT: Actually, it seems to be a matter of figure window layering order, not creation order - if I call figure(1) to bring the first figure to the top before the HARDCOPY loop, then the third case takes about as long as the second. I don't know why this only happens with 'opengl' and not 'zbuffer'.) It doesn't seem to matter if DRAWNOW is called between calls to HARDCOPY or not. Similar loops with GETFRAME are slower, but do not show a slowdown when many figures are open.
Have others seen this? Is this just an artifact of how HARDCOPY works under the hood or a possible bug? Other than closing figures, are there any workarounds? Has anyone found a faster way to capture figures/axes? Thanks.
0 件のコメント
回答 (1 件)
Jan
2012 年 6 月 18 日
On one hand I'd avoid clear all when time is measured. It removes all functions from the memory and reloading is very time-consuming.
On the other hand hardcopy with the OpenGL renderer gets the pixel values from the OpenGL driver. If a picture is covered by a lot of other figures, it is reasonable that this takes more time.
2 件のコメント
Jan
2012 年 6 月 18 日
@Andrew: You are right, no "clear all" in the code. I've read to much questions obviously.
参考
カテゴリ
Help Center および File Exchange で Graphics Performance についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!