I have a simple parfor
loop given below.
% fileAddr is a cell array of (size N) of file-addresses
sIdx = nan(N,1);
eIdx = nan(N,1);
errMsg = cell(N,1);
parfor i=1:N
[sIdx(i),eIdx(i),errMsg{i}] = myFunk(fileAddr{i});
end
The function file myFun()
loads a file given by fileAddr{i}
, makes some calculations and returns results. The file loading part is the most time consuming. My machine has 4 physical cores. I tried parfor()
with a pool o of 1,2,3 and 4 workers. Every time, the time consumption is in similar ballpark. My understanding was that if more than one worker is load()
ing the files in parallel, the program would run faster but the profiler results show otherwise.
Can anyone please explain where am I making a mistake?