Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does the first call to a Matlab DLL take much longer than subsequent calls?

I call from my C++ code a DLL that was written in MATLAB. I observe a strange effect: the first call takes much more time that the next calls. It takes 3-4 times more. Is it normal? Is it possible to do something with it?

like image 491
user1913557 Avatar asked Oct 22 '22 21:10

user1913557


1 Answers

Yes that is normal, the delay comes from starting up the MATLAB Runtime Compiler. This is what runs the MATLAB code from the dll that you created through MATLAB. The initial startup cannot be avoided AFAIK, but you can maybe add a dummy call to the DLL when your application begins in order to avoid the "cost" later.

like image 166
NominSim Avatar answered Oct 28 '22 22:10

NominSim