-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed
Labels
performanceMust go fasterMust go faster
Description
Old issue: #2360
On Julia 0.4, OSX:
function true_arr()
out = Array{Bool, 2}(300,200)
for i in eachindex(out) out[i] = true end
end
function true_bitarr()
out = BitArray{2}(300, 200)
for i in eachindex(out) out[i] = true end
end
function foo(n)
for _ in 1:n true_arr() end
end
function foo2(n)
for _ in 1:n true_bitarr() end
end@time(foo(10000))
> 0.387643 seconds (23.33 k allocations: 573.136 MB, 15.92% gc time)
@time(foo2(10000))
> 2.764923 seconds (33.85 k allocations: 73.283 MB, 0.35% gc time)
I ran into this because my code has a line:
# Comparing an image with a color returns a BitArray
img .!= green
and this calls bitneq_cache. Writing the loop explicitly yields comparable performance if I use BitArray{2}, but it's 5X faster if I use Array{Bool, 2}. That's probably because with BitArray, the set_index! call does not get inlined.
Metadata
Metadata
Assignees
Labels
performanceMust go fasterMust go faster