clear all

N = 100000;
L = 100000;

% (0-1) alloc
tic
a = zeros(N, 1);
b = zeros(N, 1);
c = zeros(N, 1);
toc

% (0-2) setup
tic
for i = 1 : N
    a(i) = i;
    b(i) = i;
end
toc

% (1) vadd
% (1-1) for
tic
for l = 1 : L
    for i = 1 : N
        c(i) = a(i) + b(i);
    end
end
toc

% (1-2) c = a + b
tic
for l = 1 : L
    c = a + b;
end
toc

% (2) sdot
% (2-1) for
tic
s = 0;
for l = 1 : L
    for i = 1 : N
        s = s + a(i) * b(i);
    end
end
toc

% (2-2) sum(a .* b)
tic
s = 0;
for l = 1 : L
    s = s + sum(a .* b);
end
toc

% (2-3) a' * b
tic
s = 0;
for l = 1 : L
    s = s + (a' * b);
end
toc
