Why does this code slow down?

1 次查看(过去 30 天)
Rosi Marungu
Rosi Marungu 2016-8-1
I am trying to run a huge simulation experiment. parameters is a cell with a 5200x1 parameter matrix in each entry. estimatedParameters has the same format. SimData is created as a 100x100x10000 matrix. estimation employs a lot of matrix inversions on 100x100 matrices.
In the first parfor iteration each iteration is done in about 300 secs. After that computational time increases gradually for each iteration and stabilizes at around 1200 secs.
Why could that be? I am not a sophisticated programmer, but in my view it seems like each iteration should take the same time.
for combo=1:4
parfor rep=1:500
tic
SimData = simulation(parameters{combo,rep});
estimatedParameters{combo,rep} = estimation(SimData);
toc
end
end
  1 个评论
Stefan Reich
Stefan Reich 2016-8-1
My guess: After the first iterations your Working Memory(RAM) fills up and Matlab starts having to shift stuff to your hard drive and back, thus slowing down and increasing calculation time. Try monitoring your RAM with the task manager during calculation. But dont take my word for it.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Scan Parameter Ranges 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by