Improving code performance by compiling
Mostrar comentarios más antiguos
Hello,
I'm coding a program where runtime is relevant, so I'm looking for ways to optimize performance. From what I've read here
the compiler / compiler SDK (don't really know the difference between the two) can create standalone apps that support most features - including graphics - but does not speed up the code since it is not compiled. The coder on the other hand can improve runtime, but does not support graphics (which I need). So in my case the only way to make use of compilation to speed up the program would be to put code into functions wherever possible and then compile those into mex files. Is that right?
4 comentarios
Mohammad Sami
el 18 de Mzo. de 2021
If you have finished building your app, use the built in profiler, to profile you app in matlab. This will help you identify areas of bottlenecks. You can then try to optimize your code.
broken_arrow
el 18 de Mzo. de 2021
Mohammad Sami
el 18 de Mzo. de 2021
Editada: Mohammad Sami
el 18 de Mzo. de 2021
As you noted, compiling the app into standalone executable will not improve the performance beyond what you have already achieved in Matlab. The only thing you can do is to vectorize your code and to follow the optimization techniques which you can find on this forum or in the help page here.
broken_arrow
el 19 de Mzo. de 2021
Respuesta aceptada
Más respuestas (1)
Pratheek
el 6 de Nov. de 2025
0 votos
Like Jan mentioned, write your code so that it is clear and easy to understand, especially on the first attempt. Avoid optimizing too early—complex code that tries to be fast from the start often does not improve performance enough to justify the loss in readability. Once it’s working, you can measure execution time and use profiling tools to locate performance bottlenecks. If speed becomes a concern, optimize only the sections that actually need improvement. MATLAB automatically manages memory for you, but if you run into memory limitations, you can evaluate how much memory your code uses and apply methods to reduce usage when necessary.
Refer the documentation for more details: https://www.mathworks.com/help/matlab/performance-and-memory.html
Categorías
Más información sobre Algorithm Design Basics en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!