Try this:
function main()
j = k = 1
t1 = @elapsed while k <= 10^8
j += k & 1
k += 1
end
j = k = 1
t2 = @elapsed while true
k > 10^8 && break
j += k & 1
k += 1
end
return t1, t2
end
# Force compilation
main()
t1s = Array(Float64, 10)
t2s = Array(Float64, 10)
for i in 1:10
t1, t2 = main()
t1s[i], t2s[i] = t1, t2
end
mean(t1s ./ t2s)
I don't see a reliable difference between the two when acquiring more data to
make a comparison that tries to overcome noise in individual measurements.
-- John
On Mar 27, 2014, at 10:02 PM, Laszlo Hars <[email protected]> wrote:
> Yes, these timings are in the global scope, but I see the same speed
> differences inside a function.