2 ms·
One thing to note is that it’s worth learning a little bit about how to write performant code in Julia and how to correctly measure its performance when evaluat
by mfsch 6y ago
One thing to note is that it’s worth learning a little bit about how to write performant code in Julia and how to correctly measure its performance when evaluating the language. It’s common for people to underestimate the performance benefits in their first experiments.
There are a few common issues: 1) You measure compilation plus execution instead of just execution. 2) Your code relies on global values that limit optimizations. 3) Your code doesn’t allow the compiler to determine all the types. 4) Your code forces allocations for intermediate values.
Especially 4) makes a big difference when you’re coming from NumPy or MATLAB. If you have a chain of vectorized operations (e.g. “X = α * A + β * B + γ * C”), the performance is quite similar between the languages, but in Julia you can enforce that these happen in-place with a single fused loop and zero allocations (e.g. adding “@.” in front). This can often give you another ~2x–10x speedup and make the difference between “similar to NumPy/MATLAB” and “similar to C/Fortran”.