Open waldie11 opened 1 year ago
Got it... Can there be done sth to help improve access natively? This does not sound like a job for AcceleratedArrays.jl, but I might be wrong.
using TypedTables
using BenchmarkTools
y = (a=1:1_000,)
x = Table(y)
v = zeros(eltype(getproperty(x,:a)),100)
function access_table!(v,x)
for i in 1:length(x)
v[i%length(v)+1] += getproperty(x,:a)[i]
end
end
@btime access_table!($v,$x)
@btime access_table!($v,$y)
5.320 μs (0 allocations: 0 bytes) 4.110 ns (0 allocations: 0 bytes)
function access_table3!(v,x::NamedTuple;label=:a)
for i in 1:length(x)
v[i%length(v)+1] += getproperty(x,label)[i]
end
end
function access_table3!(v,x::TypedTables.Table;label=:a)
z = columns(x)
return access_table3!(v,z,label=label)
end
@btime access_table3!($v,$x)
@btime access_table3!($v,$y)
4.230 ns (0 allocations: 0 bytes) 4.320 ns (0 allocations: 0 bytes)
How do I access allocation free AND flexible a TypedTable?
Nevermind the way quicker access at the NamedTuple.
5.093 μs (0 allocations: 0 bytes) 4.200 ns (0 allocations: 0 bytes)
51.871 μs (2000 allocations: 62.50 KiB) 3.800 ns (0 allocations: 0 bytes)
5.633 μs (2 allocations: 64 bytes)