Hey Julianers,
I parsed a JSON file with JSON2.jl and now I have to postprocess the results it into an Array{Array{Float32, N},1}
. The problem is that, the JSON parsed struct is an arrays of arrays of arrays of … and so on… like: Array{Array{Array{Float64,1},1},1}
or Array{Array{Array{Array{Float64,1},1},1},1}
(and it can be arbitrary dimensions in extreme cases)
I know the concrete type is array of tensors under the hood.
For me the fastest version was for Array of 2D tensors:
@time convert(Array{Array{Float32,2},1},[hcat(convert(Array{Array{Float32,1},1},arr)::Array{Array{Float32,1},1}...)' for arr in data])::Array{Array{Float32,2},1}
Can someone help me to achieve better performance?
My test code is:
@time data = [[[1::Any for i = 1:10] for j=1:10000] for k=1:100]
@time convert(Array{Array{Float32,2},1},[hcat(convert(Array{Array{Float32,1},1},arr)::Array{Array{Float32,1},1}...)' for arr in data])::Array{Array{Float32,2},1}
My results:
0.157031 seconds (1.24 M allocations: 172.817 MiB)
0.154512 seconds (1.06 M allocations: 231.872 MiB)
I see it is about 4MiB of memory. So reaching 50x bigger memory consumption size sounds like there is something wrong with my code.
How can I reach better performance?
Thanks in advance!