user1913557
user1913557

Reputation: 99

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?

Upvotes: 5

Views: 278

Answers (1)

NominSim
NominSim

Reputation: 8511

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.

Upvotes: 3

Related Questions