How to speed up your code
Posted on August 24, 2020 in Research Tricks & Tools
-
Preallocate the memory. The prepared memory will save time on finding a new address.
-
Vectorization. The program can deal with blocks instead of individual values.
-
Precalculation. You don't want to calculate repeat things, and it's better to calculate it before using it in a loop.
-
Use functions from standard libraries. These functions may run faster than yours.
-
Use more hardware. GPUs, multiple cores, and parallel your code.
Of course, using C++
rather than Python
or Malab
will also speed up your code a lot.