rng(0)
N = 1000000;
x = rand(N,1);
tester(x,500)


function out = sum0(a)
	out = sum(a);
end


function out = sum_range(a)
	total = zeros(1,1,class(a));
	for i=1:numel(a)
		total = total + a(i);
	end
end


function tester(x,nrep)
	flist = {@sum0, @sum_range};
	for i=1:numel(flist)
		f = flist{i}
		tic
		for k=1:nrep
			f(x);
		end
		toc
	end
end
