Slow code can be written in any language
-
put your code performance critical code into a function
-
type stability (
@code_warntype
is your friend) -
only use
const
globals in performance critical code -
benchmark your code: use
@time
(run twice to compile it) or better@btime
from BenchmarkTools.jl -
profile your code:
-
before starting performance tuning, it's good to setup tests to make sure your code outputs the same
Use the $
trick with the @btime
macro:
a = rand(5)
@btime sin.($a)
-
First and foremost: Performance Tips in the Julia documentation
-
Dirty trick: go on Julia Discourse and state that you ported code from Matlab/Python/R to Julia and it's now slower... (do use resources of other people very sparingly!)
Take your Game of Life code and improve its performance.
If you did not code a solution, take the one here