Same code taking 15x longer to execute on a faster machine
2 views (last 30 days)
Show older comments
I recently upgraded to a faster computer (from a 16Gb i7 processor to a 32Gb RYZEN processor with a 16Gb NIVIDIA RTX GPU (CUDA compatible)).
I used to execute the following code in a matter of 5-10 seconds on my older machine (MATLAB 2021a). Now it is taking >2 minutes on a way faster machine (MATLAB 2022b).
I think it is related to a certain memory allocation setting in MATLAB which I might have applied on my previous machine, but I can't remember it anymore.
Is there someone who could help me in resolving this issue, please? For example, which setting I could modulate to execute this code faster?
Or is it is related to the MATLAB version?
dE00=zeros(6,7362497,"single"); %dE00 refers to a numerical value of color difference
% lab_NF contains six CIELAB color values (L*, a* and b*) while labDB is a
% database of 7362497 CIELAB color values.
for nClrs=1:7362497
dE00(1:6,nClrs)=deltaE2000(lab_NF(1:6,1:3),labDB(nClrs,1:3));
end
Thanks in advance!
17 Comments
Bruno Luong
on 17 Nov 2022
Edited: Bruno Luong
on 17 Nov 2022
I run gain the code on my Intel laptop
R2021a: 85 seconds
R2022b: 87 seconds
Accepted Answer
Jan
on 17 Nov 2022
n = 32000; % 7362497;
dE00 = zeros(6, n,"single");
lab_NF = rand(6, 3, 'single');
labDB = rand(n, 3, 'single');
tic
for nClrs = 1:n
dE00(1:6, nClrs) = deltaE2000(lab_NF(1:6, 1:3), labDB(nClrs, 1:3));
end
toc
% Faster without explicit indexing:
tic
for nClrs = 1:n
dE00(:, nClrs) = deltaE2000(lab_NF, labDB(nClrs, :));
end
toc
More Answers (0)
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!