[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Ops on matrix in cell array much slower than on bare matrix
From: |
Glenn Golden |
Subject: |
Ops on matrix in cell array much slower than on bare matrix |
Date: |
Thu, 08 Jan 2004 19:49:18 -0700 |
Any ideas on this? It's eating my lunch, and the workaround is very
ugly. See comments in script.
Octave version = 2.1.50.
Thanks,
Glenn Golden
===== begin example script =====
ysize = 100000;
nloops = 1000;
#
# Loop to evaluate execution time of assignment of a scalar to a matrix
# element. On my machine, with parameters above, execution time per
# assignment is around 20 usec.
#
Y = zeros(ysize,1);
start = cputime();
for k = 1:nloops
Y(1) = 123.4;
endfor
et = cputime() - start;
fprintf(stderr, "et/assignment = %f\n", et/nloops);
#
# Same thing as above, except using cell array to hold the matrix. Average
# execution time per assignment is around 100 times larger (2.3 ms) than
# above. The slowdown factor is related to the size of the matrix (ysize).
#
y = cell(1,2);
y{1} = zeros(ysize,1);
start = cputime();
for k = 1:nloops
y{1}(1) = 123.4;
endfor
et = cputime() - start;
fprintf(stderr, "et/assignment = %f\n", et/nloops);
===== end example script =====
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------
- Ops on matrix in cell array much slower than on bare matrix,
Glenn Golden <=