print function with contour too slow

Hi:
I met a problem using 'print' function to print contour to 'jpeg' file. I found some suggestions in web: https://www.mathworks.com/matlabcentral/answers/96864-why-does-the-print-command-take-so-long-with-a-scatter-plot-in-matlab-7-5-r2007b, which suggests to print to 'EPS' format would be faster, however, I tested print both 'jpeg' and 'EPS' format, the result looks quite similar.
is there anyway to optimize this process? I attached a sample for test, the data is the 1st graph in a 3*3 contour, it cost about 90 seconds in my side to print the full graph, in both '.jpeg' and '.eps' format.
the test data 'f.mat' is too large, I compress it to .7z and the .zip, therefore, it requires to extract two times.
Thanks!
Yu

回答 (1 件)

OCDER
OCDER 2018 年 8 月 1 日

0 投票

Here are the times in my computer. Do you need the '-tiff', '-r600' option for eps file?
tic
print('EPS_test.eps','-depsc2','-opengl');
toc %0.45s
tic
print('EPS_test.eps','-depsc2','-painters');
toc %3.63s
tic
print('EPS_test.eps','-depsc2','-tiff', '-r600');
toc %2.52s
tic
print('EPS_test.jpg','-djpeg', '-r600');
toc %1.12s

13 件のコメント

Yu Li
Yu Li 2018 年 8 月 1 日
編集済み: Yu Li 2018 年 8 月 1 日
Hi:
thanks for your reply, perhaps it is due to my CPU (2.6 GHz), I tried all the four choices your provided, all of them are over 10 seconds.
meanwhile, I could not see any big difference between these four choices. if load the 'f.mat' into Matlab and print it once, the printing time is significantly reduced if you print them the second time without clear them in workspace. for example:
clear all
clc
load f
tic
print('EPS_test.eps','-depsc2','-tiff','-r600');
toc
clear all
load f
tic
print('JPG_test.jpeg','-djpeg','-r600');
toc
Elapsed time is 12.108189 seconds. Elapsed time is 10.932509 seconds.
clear all
clc
load f
tic
print('EPS_test.eps','-depsc2','-tiff','-r600');
toc
tic
print('JPG_test.jpeg','-djpeg','-r600');
toc
Elapsed time is 11.898137 seconds. Elapsed time is 1.717132 seconds.
therefore just want to make sure if you have clear the parameters in Matlab before print them.
Thanks
Yu
OCDER
OCDER 2018 年 8 月 1 日
Actually, better to not use clear at all, as that's slow. Also, better practice is use a load with an output.
A = load('f.mat', 'f'); %A.f will be your figure handle
print(A.f, 'EPS_test.eps', '-depsc2')
Yu Li
Yu Li 2018 年 8 月 1 日
Hi:
Thanks for your reply. But the printing time is still too slow. I guess it may be due to my CPU. could you please let me know what you CPU is? The result shows that it is much faster than mine.
Thanks! Yu
OCDER
OCDER 2018 年 8 月 1 日
12 GB RAM + Quad core 3.2 Ghz. You have 96GB RAM + 2.7 GHz, which should be fairly fast. Something is indeed wrong... Update graphics card maybe?
Yu Li
Yu Li 2018 年 8 月 1 日
My graphid card is 980ti (6GB), which is for more enough to handle this kind of display I think. BTW, the disk I tried to print to is 960EVO SSD, therefore this should not be the problem.
OCDER
OCDER 2018 年 8 月 1 日
Oh, I meant update graphic card DRIVER, not graphics card. That's a nice computer by the way! 11s saving time is indeed very weird.
Yu Li
Yu Li 2018 年 8 月 1 日
I do not think print function will not use graphic card since it does not display any figures in this case.
OCDER
OCDER 2018 年 8 月 1 日
編集済み: OCDER 2018 年 8 月 1 日
I'm not too sure about this, but seems like print uses a renderer behind the scene to save an image. opengl vs painters.
And opengl can use GPU for hardware acceleration, if enabled.
See if changing opengl options - hardware vs software help:
Yu Li
Yu Li 2018 年 8 月 1 日
Thanks for your reply. I’ll do a case study and Alger back to you with what I find.
Regards, Yu
Yu Li
Yu Li 2018 年 8 月 1 日
編集済み: Yu Li 2018 年 8 月 1 日
Hi:
there is no significantly improvement by changing the openGL, below are the codes:
clear all
clc
load f
opengl software
tic
print('EPS_test.eps', '-depsc2','-tiff','-r600')
toc
load f
opengl hardware
tic
print('EPS_test.eps', '-depsc2','-tiff','-r600')
toc
load f
opengl hardwarebasic
tic
print('EPS_test.eps', '-depsc2','-tiff','-r600')
toc
Elapsed time is 10.353922 seconds.
Elapsed time is 9.846934 seconds.
Elapsed time is 9.997695 seconds.
below are my Graphic card info:
Version: '4.5.0 NVIDIA 375.70'
Vendor: 'NVIDIA Corporation'
Renderer: 'GeForce GTX 980 Ti/PCIe/SSE2'
RendererDriverVersion: '21.21.13.7570'
RendererDriverReleaseDate: 25-Oct-2016
MaxTextureSize: 16384
Visual: 'Visual 0x09, (RGBA 32 bits (8 8 8 8), Z depth 16 bits, Hardware acceleration, Double buffer, Antialias 8 samples)'
Software: 0
HardwareSupportLevel: 'basic'
SupportsGraphicsSmoothing: 1
SupportsDepthPeelTransparency: 0
SupportsAlignVertexCenters: 0
Extensions: {357×1 cell}
MaxFrameBufferSize: 16384
after updated the Graphic card driver to the newest version, there is still no improvement observed, even a little slower than before:
Elapsed time is 11.119153 seconds.
Elapsed time is 10.032643 seconds.
Elapsed time is 10.178713 seconds.
Thanks!
Yu
OCDER
OCDER 2018 年 8 月 1 日
I'm running out of idea o_O. -deps/-depsc/-depsc2, -painters are what's left to test for the print options
Maybe this latest driver released Aug 1, 2018 might help? I'll admit, it's a long shot. https://www.geforce.com/drivers/results/136673
If you can't get this resolved, you could try to contact Mathworks directly for support using that Contact Us link.
Yu Li
Yu Li 2018 年 8 月 1 日
The newest version of driver does not work.
Elapsed time is 11.648357 seconds.
Elapsed time is 10.213246 seconds.
Elapsed time is 9.919810 seconds.
however thank you the same for your help.
Bests Yu
OCDER
OCDER 2018 年 8 月 1 日
You're welcome. Hope you find a solution soon! If you do figure it out, post in the Answer section to help others with similar issues.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeGraphics Performance についてさらに検索

質問済み:

2018 年 7 月 31 日

コメント済み:

2018 年 8 月 1 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by