Dear all,
Here is an other simple example of
the slowness of the new HG2 graphic engine.
Please, run the code 'testSpeed' below and give us
your time-readings with your Matlab-version.
Thanks.
Mine results on the same computer are:
% =======================================
Creating axes in Matlab-2014a: 0.14476
Creating text in Matlab-2014a: 0.09161
% =======================================
Creating axes in Matlab-2015a: 2.1895
Creating text in Matlab-2015a: 11.0135
% =======================================
So:
creating axes in R2015a is 15x slower than R2014a
creating text in R2015a is 120x (!) slower than R2014a
% ===================================================
function testSpeed
getVersion = version('-release');
% Get pixel-dimensions of the Monitor
screenSize = get(groot, 'screenSize'); % screenSize = get(0, 'screenSize');
% Set Figure-dimensions depending of Monitor-dimensions
hFig = figure('position', [screenSize(1) + 5 50 screenSize(3) - 10 screenSize(4) - 135]);
figSize = get(hFig, 'position');
% Set Panel-dimensions depending of Figure-dimensions
hPanel = uipanel( ...
'parent', hFig, ...
'units', 'pixels', ...
'position', [5 5 figSize(3) - 10 figSize(4) - 20], ...
'back', [1 1 1]);
panelSize = get(hPanel, 'position');
% Total of 40 rows and 10 koloms in the Panel
nRows = 40; nKols = 10;
% Set Height and Width of the 400 Axes depending of Panel-dimensions
heigth = (panelSize(4) - 2) / nRows;
width = (panelSize(3) - 2) / nKols;
% Pre-allocation of Axes- and Text-handles
hAxes = gobjects(nRows, nKols); % hAxes = zeros(nRows, nKols);
hText = gobjects(nRows, nKols); % hText = zeros(nRows, nKols);
colorAxes = [1 1 1] * 0.9; fontSize = heigth / 2;
% ========== Creating axes in the Panel ======================
tic
for iRow = 1:nRows
for iKol = 1:nKols
hAxes(iRow, iKol) = axes ( ...
'parent', hPanel, ...
'units', 'pixels', ...
'pos', [1 + (iKol - 1) * width, panelSize(4) - iRow * heigth, width, heigth], ...
'color', colorAxes, ...
'box', 'on', ...
'xcolor', 1 - colorAxes, ...
'ycolor', 1 - colorAxes, ...
'xtick', [], ...
'ytick', [], ...
'vis', 'on');
end % for iKol=1:nKols
end % for iRow = 1:nRows
t1 = toc;
disp (['Creating axes in Matlab-' getVersion ': ' num2str(t1)])
% =========== Creating text in the Axes ====================
tic
for iRow = 1:nRows
for iKol = 1:nKols
hText(iRow, iKol) = text ( ...
'parent', hAxes(iRow, iKol), ...
'units', 'pixels', ...
'pos', [9 fontSize], ...
'color', 'k', ...
'string', [' Graphics - ' getVersion], ...
'fontname', 'helvetica', ...
'fontsize', fontSize, ...
'vis', 'on', ...
'userdata', [iRow, iKol]);
end % for iKol=1:nKols
end % for iRow = 1:nRows
t2 = toc;
disp (['Creating text in Matlab-' getVersion ': ' num2str(t2)])
end % function testSpeed
% ===================================================