Improving code performance by compiling
古いコメントを表示
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 件のコメント
Mohammad Sami
2021 年 3 月 18 日
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
2021 年 3 月 18 日
Mohammad Sami
2021 年 3 月 18 日
編集済み: Mohammad Sami
2021 年 3 月 18 日
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
2021 年 3 月 19 日
採用された回答
その他の回答 (1 件)
Pratheek
2025 年 11 月 6 日
0 投票
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
カテゴリ
ヘルプ センター および File Exchange で Algorithm Design Basics についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!