MATLAB executable is too slow

A MATLAB compiled .exe will suffer from overhead at the first time you run it becuase it is starting the MCR: Why does my application compiled with the MATLAB Compiler 4.1 take a long time to start up?

Unless you log off or restart your OS, the MCR will remain pre-loaded. Another useful read: Speeding up compiled apps startup.

Why does my stand-alone created using the MATLAB Compiler take longer to start the first time?” also reports that consecutive runs should be faster, but if you rerun later, you will have to reload the process in memory.

You can enclose your code within tic toc, deploy it and check how much time the execution is taking, against startup overhead.

The alternative to speeding up the .exe would be to call MATLAB with PHP. If you keep the MATLAB session open you run into the overhead once. You could launch MATLAB at startup, thus avoiding to suffer the overhead specifically during the call with PHP.

For more info read Calling MATLAB from PHP, and keep in mind that you don’t want to use exit unless specifically needed.

Leave a Comment