June 2019
Intermediate to advanced
218 pages
5h 19m
English
A simple way to get the performance back is to declare the global variable a const declaration:
const p2 = 2 function pow_array2(x::Vector{Float64}) s = 0.0 for y in x s = s + y^p2 end return s end
This one change will get us a little under two orders of magnitude performance gain on the following function:
julia> @btime pow_array2($t) 103.506 μs (0 allocations: 0 bytes)33240.25981204582
Read now
Unlock full access