矢量化时，Tuple的Vector如何分配比较快？

``````using BSON: @load
using BenchmarkTools

const restenergy = 0.511e6            # [eV]

nturns = 10001

struct Par
v1
r
ϕs
ϕ2s
h1
h
circum
centerenergy
αc
end

function revolution(z, δ, p::Par)
δ = δ + p.v1 * (sin(p.ϕs - 2 * p.h1 * π * z / p.circum) - sin(p.ϕs) + p.r * sin(p.ϕ2s - 2 * p.h1 * p.h * π * z / p.circum) - p.r * sin(p.ϕ2s)) / p.centerenergy / p.circum
η = p.αc - 1 / (p.centerenergy * (1 + δ) / restenergy)^2
z = z - η * δ
z, δ
end

function main!(zvec, δvec, nturns, p::Par)
npart = size(zvec, 1)
zmat = zeros(npart, nturns)
δmat = zeros(npart, nturns)

for i = 1:nturns
zvec, δvec = revolution.(zvec, δvec, p)
zmat[:, i] .= zvec
δmat[:, i] .= δvec
end
end

p = Par(3.6395053705870048e+06,0.1801760487622639,2.1575815005097385,6.0620746573056303,756,3,1360.4,6e9,0.0000156)
@benchmark main!(\$zvec, \$δvec, \$nturns, \$p)
``````

``````@load "zvec_δvec.bson" zvec δvec
``````

``````zvec, δvec = revolution.(zvec, δvec, p)
``````

``````julia> a, b = [1,2,3,4,5]
5-element Vector{Int64}:
1
2
3
4
5

julia> a
1

julia> b
2
``````