Hi,
I am running a GUI where I continuously update the data of some plots in a figure. Now I have some issue with performance and started profiling the scripts. It turns out that there is a call for legend layout during each "drawnow" command. I have tried to isolate the problem, and it appears as follows:
% Head-on approach
>> figure
>> h = plot(rand(1,100));
>> l = legend('test');
>> tic,for n = 1:100, set(h, 'ydata', rand(1,100)); drawnow; end,toc
% Elapsed time is 2.950091 seconds.
% Now I tried solving the problem by removing the colorbar layout listeners:
>> legendcolorbarlayout(gca, 'remove') % helper function for legend/colorbar
>> tic,for n = 1:100, set(h, 'ydata', rand(1,100)); drawnow; end,toc
% Elapsed time is 0.323518 seconds.
So, it ran 9 times faster... but there must be a better way to do this with the legend command or similar? Perhaps an option to using drawnow?
|
|
0
|
|
|
|
Reply
|
fredrik.moeschlin (1)
|
1/27/2010 2:50:05 PM |
|