% Script Bench3
% Compare a column-oriented compuation with an equivalent row-oriented
% computation.

clc
n = 2000;
A = randn(n,n);
% Add up the values in A.
% Method 1 is column-oriented...
tic
s = 0;
for k=1:n
s = s+sum(A(:,k));
end
t1 = toc;
% Method 2 is row-oriented...
tic
s = 0;
for k=1:n
s = s+sum(A(k,:));
end
t2 = toc;
fprintf('Row-Oriented Time / Column-Oriented Time = %5.2f\n',t2/t1)