Chapter 9. Performance
using Pkg
using BenchmarkTools
iterations = zeros(10000)
println("")1. Faster for-loop using @inbounds
@inboundsiterations = zeros(1000000)
function iter_with_inbounds(arr)
@inbounds for i in 1:length(arr)
arr[i] = 1.0
end
end
function iter(arr)
for i in 1:length(arr)
arr[i] = 1.0
end
end2. Avoid untyped global variables
3. Check performance

4. More on...
Last updated