-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Performance of ReinterpretArray, continued #28980
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Please don't use |
Fair enough; that code was extracted (with minor changes to make it stand-alone) from a current package where one hopes the A cleaner case, from ImageCore, boils down to this: const old = VERSION < v"0.7"
ssz = (1000,1000)
c = rand(RGB{Float64}, ssz...)
if old
a = copy(reinterpret(Float64, c))
else
a = copy(reinterpretc(Float64, c))
end
vchan = channelview(c)
vcol = colorview(RGB, a)
function myfill1!(A, val)
for I in eachindex(A)
A[I] = val
end
A
end
const zcol = zero(eltype(vcol))
const zchan = zero(eltype(vchan))
println("VERSION: ",VERSION)
println("arg type: ",typeof(vcol))
@btime myfill1!($vcol,zcol)
println("arg type: ",typeof(vchan))
@btime myfill1!($vchan,zchan)
|
And to follow up on the original example, removing the pointless copy with function fillcolor1!(buffer::AbstractArray{T, 3}, imgsrc, nc) where T
buffer[:, :, :] = imgsrc
end B-times: function fillcolor2!(buffer::AbstractArray{T, 3}, imgsrc, nc) where T
buffer .= imgsrc
end v0.6.4 |
Could we revive #27213, now that the 1.0 release is done? That seemed significantly less complex, more robust and more elegant than the alternatives. |
using Images 7.160414 seconds (21.85 M allocations: 1.549 GiB, 9.59% gc time) |
Bump. using ColorTypes, BenchmarkTools
# Julia 0.6
julia> @btime rand(RGB{Float64}, 20, 20);
1.855 μs (3 allocations: 9.59 KiB)
# Julia 1.2
julia> @btime rand(RGB{Float64}, 20, 20);
12.046 μs (3 allocations: 9.58 KiB) |
Although the problem described in #25014 was handled by #28707, there is more to be done.
To start, can the pattern of the latter PR be extended to
setindex
?Example (based on a regression in QuartzImageIO)
v0.6.4:
v0.7.0:
v1.1.0-DEV.140:
Are the two versions of
fillarray
guaranteed to have equivalent results? If so, could the first now be made to throw?The text was updated successfully, but these errors were encountered: