Hello,
a simple test return strange results …
I’ve placed in a file speed05vs06.jl
following code:
function speedtest()
a = [1:10...]
b = 2*a + 1
@show a
@show b
if (VERSION < v"0.6.0")
@time v = (a .< 7) & (b .< 7)
@time v = (a .< 7) & (b .< 7)
else
@time v = (a .< 7) .& (b .< 7)
@time v = (a .< 7) .& (b .< 7)
end
return v
end
After including code with include("speed05vs06.jl")
and running it with speedtest()
, I obtain these results on same machine:
Julia 0.5.2:
julia> speedtest()
a = [1,2,3,4,5,6,7,8,9,10]
b = [3,5,7,9,11,13,15,17,19,21]
0.088614 seconds (5.69 k allocations: 263.064 KB)
0.000035 seconds (11 allocations: 8.797 KB)
10-element BitArray{1}:
true
true
false
false
false
false
false
false
false
false
Julia 0.6.2:
julia> speedtest()
a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
b = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21]
3.140345 seconds (150.74 k allocations: 7.619 MiB)
0.077298 seconds (8.67 k allocations: 453.101 KiB)
10-element BitArray{1}:
true
true
false
false
false
false
false
false
false
false
then Julia 0.5.2 seems to be faster for array operations than Julia 0.6.2!
(also excluding 1st execution, due to precompilation)
I’ve read https://docs.julialang.org/en/latest/manual/performance-tips/ , especially “More dots” paragraph, but I’m still confused …
Anyone can explain what’s wrong in my code?
Many thanks in advance
Leonardo