Same code taking 15x longer to execute on a faster machine

조회 수: 5 (최근 30일)
Aiman Raza
Aiman Raza 2022년 11월 16일
댓글: Aiman Raza 2022년 11월 17일
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
Bruno Luong
Bruno Luong 2022년 11월 17일
편집: Bruno Luong 2022년 11월 17일
I run gain the code on my Intel laptop
R2021a: 85 seconds
R2022b: 87 seconds
Aiman Raza
Aiman Raza 2022년 11월 17일
So it clearly is my machine which is just not great. I will try to rewrite the code more smartly to improve the processing duration. Thanks a lot.

댓글을 달려면 로그인하십시오.

채택된 답변

Jan
Jan 2022년 11월 17일
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
Elapsed time is 1.013390 seconds.
% Faster without explicit indexing:
tic
for nClrs = 1:n
dE00(:, nClrs) = deltaE2000(lab_NF, labDB(nClrs, :));
end
toc
Elapsed time is 0.722065 seconds.
  댓글 수: 1
Aiman Raza
Aiman Raza 2022년 11월 17일
편집: Aiman Raza 2022년 11월 17일
Thanks a lot! Removing the indexing did reduce the time to 106s. It is still better than before. I will try to code without a loop. That might further improve the timing.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by