13 Jan 2025
Note
Using function is fundamental for to generate performant code. If you want something to be fast, put it inside a function!
vs
This approach provides no performance benefit, only use for dispatch! 1 This does not enable to write general code.
In Julia, you can extend any function based on a custom type. Only extend a function for a given type if:
@time
The time macro is used as a basic benchmarking tool.
@profview
In VSCode, this is imported by default.
@benchmark
(from BenchmarkTools)If you want fancy histograms. Gold standard.
In Julia, multi-dimensional arrays are stored as a long column. So iterating in the first index is more efficient.
view
By default this generates a copy of the array’s data
To pass it as a “pointer” to the data, it is recommended to use view
.
In memory if the container is not typed, each element also need to store its type.
Solution: - Specify container type, {numbers = Int[]
Solutions:
const
(can’t change type) const x = 10
f(n) = n + 10
Solution:
struct
paddingSolution:
Initialize with correct type
Advanced Scintific Computing Using Julia