#572 Slow performance when working with cell arrays

No version
open
nobody
5
2012-09-26
2012-09-26
Jed Pack
No

I am not sure this is really a "bug", but I get much slower performance in the first code block than the second. Note that I am only timing one of the lines in each block. The only difference is the use of a cell array in the first block instead of a regular variable. Any idea why this happens? I have seen this problem on three different FreeMat installations (all the ones I have tested): Linux, FreeMat version 3.5, Windows, Freemat version 3.5 and Windows, FreeMat version 4.2 beta (downloaded minutes ago). The discrepancy is much larger in 3.5 (mostly because the second one is much faster in 3.5):

clear all
vol{1} = zeros(512,512,100);
a = vol{1}(:,:,1);
a(1) = 7.0;
tic;
vol{1}(:,:,1) = a;
t=toc

clear all
vol = zeros(512,512,100);
a = vol(:,:,1);
a(1) = 7.0;
tic;
vol(:,:,1) = a;
t=toc

Discussion

  • Samit Basu
    Samit Basu
    2013-03-31

    Hi Jed! Did you have some other "slow performance" related issues? I seem to recall some problems around structures instead of cell arrays?

    Samit