Generate compiled C code function including logging instrumentation
buildInstrumentedMex
translates the MATLAB® file fcn
-options
to a MEX function and
enables instrumentation for logging minimum and maximum values of all named and intermediate
variables. Optionally, you can enable instrumentation for log2 histograms of all named,
intermediate and expression values. The general syntax and options of
fcn
.mbuildInstrumentedMex
and fiaccel
are the same, except buildIntstrumentedMex
has no
fi
object restrictions and supports the '-coder'
option.
buildInstrumentedMex
translates the MATLAB functions fcn
_1... fcn
_n -options
-coder
through
fcn_1
to a MEX function and enables
instrumentation for logging minimum and maximum values of all named and intermediate
variables. Generating a MEX function for multiple entry-point functions requires the
fcn_n
'-coder'
option.
You cannot instrument MATLAB functions provided with the software. If your top-level function is such a MATLAB function, nothing is logged. You also cannot instrument scripts.
Instrumentation results are accumulated every time the instrumented MEX function is
called. Use clearInstrumentationResults
to clear
previous results in the log.
Some coding patterns pass a significant amount of data, but only use a small portion
of that data. In such cases, you may see degraded performance when using
buildInstrumentedMex
. In the following pattern,
subfun
only uses one element of input array, A
.
For normal execution, the amount of time to execute subfun
once remains
constant regardless of the size of A
. The function
topfun
calls subfun
N
times, and thus the total time to execute topfun
is proportional to N
. When instrumented, however, the time to execute
subfun
once becomes proportional to N
^2. This
change occurs because the minimum and maximum data are calculated over the entire array.
When A
is large, the calculations can lead to significant performance
degradation. Therefore, whenever possible, you should pass only the data that the function
actually
needs.
function A = topfun(A) N = numel(A); for i=1:N A(i) = subfun(A,i); end end function b = subfun(A,i) b = 0.5 * A(i); end function A = topfun(A) N = numel(A); for i=1:N A(i) = subfun(A(i)); end end function b = subfun(a) b = 0.5 * a; end
clearInstrumentationResults
| fiaccel
| mex
| NumericTypeScope
| showInstrumentationResults
| codegen
(MATLAB Coder)