Hi there! I’m new in the Julia ecosystems and my first project is trying to simulate a particular random circuit using Yao. My issue at the moment is basically the efficiency of code which seems to be quite slow. I would really appreciate any suggestion/advice on how to improve the code.

```
function circuit_layer(n::Int, β::Array{Float64, 1}, epsilon::Float64)
U = chain(n)
append!(U, chain(n, put(n, loc=>chain(rand(rng,randG)((2*rand())*epsilon*π))) for loc = 1:n))
for j = 1:n-1
append!(U, chain(n, subroutine(n, rot(ZZ, β[j]), (j, j+1))))
end
return U
end
function get_entropy_evolution(pmax::Int, spacing::Float64, n::Int, nA::Int, epsilon::Float64)
fp = trunc(log2(pmax))
times = union(trunc.([2^i for i in 1:spacing:fp]))
ψ = Yao.uniform_state(n)
result = zeros(length(times))
count = 0
for t in 1:pmax
β = (π*0.5)*(2.0*rand(n-1) .- 1.0)
ψ |> circuit_layer(n, β, epsilon)
if (t in times) == true
count = count + 1
result[count] = entropy(state(ψ), n, nA, 1)
end
end
result
end
```

The code works as follows: 1.) Construct one layer of the circuit, that is captured by the function `circuit_layer`

, 2.) Then “time evolve” the state and only compute entropy at certain points in time.

I know the function `svdvals`

is costly but in principle, it shouldn’t be a problem for system sizes around N=20