Why Abstract Type is slow?


#1

Can anyone answer about this question?
Why use of Integer type makes program slower.
If you run the below code, you might see it takes about 0.13 second to use the data of type UnitRange{Integer}.

repetition = 30
mat = rand(1000,1000)
unitrange_integer = UnitRange{Integer}(1:250)
unitrange = UnitRange(1:250)

times_unitrange_integer = Vector{Float64}()
for i=1:repetition
	push!(times_unitrange_integer, @elapsed mat[unitrange_integer, unitrange_integer])
end

times_unitrange = Vector{Float64}()
for i=1:repetition
	push!(times_unitrange, @elapsed mat[unitrange,unitrange])
end

times_hardcoding = Vector{Float64}()
for i=1:repetition
	push!(times_hardcoding, @elapsed mat[1:250,1:250])
end

println(median(times_unitrange_integer),"\t", median(times_unitrange), "\t", median(times_hardcoding))

#2

I thought the comment in the issue you post is already clear enough. If not please first read the doc.