model = ABM(Agent3, GridSpace((100, 100)))
for _ in 1:500
add_agent!(model, rand())
end
aos = collect(values(model.agents)) # 1.770 μs (1 allocation: 4.06 KiB)
soa = StructArray(values(model.agents)) # 3.966 μs (12 allocations: 16.22 KiB)
# ^^ initialisation is slower here, but maybe not with a better collection method
julia> @btime sum(a->a.weight, $aos)
428.955 ns (0 allocations: 0 bytes)
252.1354667521684
julia> @btime sum($soa.weight)
57.521 ns (0 allocations: 0 bytes)
252.13546675216827