generate compiled c code function including logging instrumentation -凯发k8网页登录
generate compiled c code function including logging instrumentation
description
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 are the same, except buildintstrumentedmex
has no
fi
object restrictions and supports the '-coder'
option.
note
like the function, the
buildinstrumentedmex
function generates a mex function. to
generate c code, use the codegen
(matlab coder) function.
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.
note
generating a mex function for multiple entry-point functions using the
buildinstrumentedmex
function requires a matlab
coder™ license.
examples
input arguments
tips
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 executesubfun
once remains constant regardless of the size ofa
. the functiontopfun
callssubfun
n
times, and thus the total time to executetopfun
is proportional ton
. when instrumented, however, the time to executesubfun
once becomes proportional ton
^2. this change occurs because the minimum and maximum data are calculated over the entire array. whena
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
version history
introduced in r2011bsee also
| clearinstrumentationresults
| showinstrumentationresults
| | codegen
(matlab coder) |