How can I improve CPU usage for a compiled standalone executable?

I am using MATLAB Compiler in MATLAB R2019b to create a standalone executable with a complex UI. When I run the executable on my desktop computer, the CPU usage for the application is around 15-20%, but when I deploy the executable to a Microsoft Surface, the CPU usage is around 40-50%. How can I decrease this?

 Réponse acceptée

Because you are using a standalone executable, it comes packaged with MATLAB Runtime (MCR), which will inherently take up a lot of your machine's resources. You should expect to see similar performance and resource utilization as you see in MATLAB. The MCR is essentially what allows the compiled application to run on machines that do not have MATLAB installed.
Based on the type of application you are compiling, there are a few ways to try to improve CPU usage. However, note you might only be able to improve the performance marginally using these methods.
  1. As of MATLAB R2019b, you can try to programmatically create the UI instead of using GUIDE or AppDesigner.
  2. Try to make use of MEX files for some aspects of your application. In general, directly writing C or C++ code can be more efficient than the higher level MATLAB functions available, which can then be compiled with "mex" and used with your MATLAB code.
  3. If you are deploying to machines that have a GPU available, you may be able to switch some of the processing from the CPU to the GPU. However, this limits the types of machines you can deploy this application to. 
  4. Try to implement parallelization in some steps your code. With the Parallel Computing Toolbox, you might be able to introduce multiple workers to handle different parts of processing simultaneously and then pass data to another worker/the UI. 

Plus de réponses (0)

Catégories

Produits

Version

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by