I have just started using V4.0 of the compiler and am doing some
I am interested particularly in calling Matlab functions from a C++
program. From my initial tests, I am concerned about the cost of
invoking a function.
Calling a compiled version of the the following minimal function:
function [ out ] = return_input( in )
out = in;
....from a C++ application takes an average of 15 ms per call
(averaged over 1000 calls).
As a comparison from Matlab console, it takes 6 microseconds (1/2500
of the time).
for ( i=1:1000000 )
return_input( 99.9 );
Elapsed time is 6.610000 seconds.
An observation of what happens when calling from C++ is that it does
not seem to be CPU bound (CPU usage is down at 1-2% during the test).
Has anyone else noticed this? I am confused as to what is causing
this overhead - I see minimal CPU usage, no page-faulting, no I/O
reads or writes.
As a more minor point, the 1.5 - 2 seconds it takes to initialise the
runtime seems a bit excessive (but maybe this is because I am used to
previous versions of the Matlab compiler, where this wasn't an issue
at all ;)
Thanks in advance,