I have made a minimum test case:
a=rand(10000,2)
function newsum(a)
for i in 1:100
sum(a[:,1])+sum(a[:,2])
end
end
function newsum(a1,a2)
for i in 1:100
sum(a1)+sum(a2)
end
end
@time newsum(a)
@time newsum(a[:,1],a[:,2])
elapsed time: 0.073095574 seconds (17709844 bytes allocated, 23.23% gc time)
elapsed time: 0.006946504 seconds (244796 bytes allocated)
I suggest that a[:,1] is making a copy of the data in the a matrix this is done
in each iteration of the first function, but in the second function this is
done only once when the function is called like: newsum(a[:,1],a[:,2]).