"@allocated sum_rand(length(x))      # 16"

Here you access x which is a non const global variable.

If you want to use global variables and have good performance, use "const".

julia> const x = rand(100);

julia> @allocated sum_rand(length(x)) 
0

Reply via email to