Control Run-Time Checks
Types of Run-Time Checks
The code generated for your MATLAB®functions includes the following run-time checks and external calls to MATLAB functions.
Memory integrity checks
These checks detect violations of memory integrity in code generated for MATLAB functions and stop execution with a diagnostic message.
Caution
These checks are enabled by default. Without memory integrity checks, violations result in unpredictable behavior.
Responsiveness checks in code generated for MATLAB functions
These checks enable periodic checks for Ctrl+C breaks in code generated for MATLAB functions. Enabling responsiveness checks also enables graphics refreshing.
Caution
These checks are enabled by default. Without these checks, the only way to end a long-running execution might be to terminate MATLAB.
Extrinsic calls to MATLAB functions
Extrinsic calls to MATLAB functions, for example to display results, are enabled by default for debugging purposes. For more information about extrinsic functions, seeDeclaring MATLAB Functions as Extrinsic Functions.
When to Disable Run-Time Checks
Generally, generating code with run-time checks enabled results in more generated code and slower MEX function execution than generating code with the checks disabled. Similarly, extrinsic calls are time consuming and increase memory usage and execution time. Disabling run-time checks and extrinsic calls usually results in streamlined generated code and faster MEX function execution. The following table lists issues to consider when disabling run-time checks and extrinsic calls.
Consider disabling... | Only if... |
---|---|
Memory integrity checks | 你已经证实数组界限和dimension checking is unnecessary. |
Responsiveness checks | You are sure that you will not need to stop execution of your application using Ctrl+C. |
Extrinsic calls | You are using extrinsic calls only for functions that do not affect application results. |
How to Disable Run-Time Checks
You can disable run-time checks explicitly from the project settings dialog box, the command line, or a MEX configuration dialog box.
Disabling Run-Time Checks Using theMATLABCoder应用程序
To open theGeneratedialog box, on theGenerate Codepage, click theGeneratearrow
.
SetBuild typeto
MEX
.ClickMore Settings.
On theSpeedtab, clearEnsure memory integrity,Enable responsiveness to CTRL+C and graphics refreshing, orKeep Extrinsic calls, as applicable.
Disabling Run-Time Checks From the Command Line
在MATLAB工作区,define the MEX configuration object:
mexcfg = coder.config('mex');
At the command line, set the
IntegrityChecks
,ExtrinsicCalls
, orResponsivenessChecks
properties to false, as applicable:mexcfg.IntegrityChecks = false; mexcfg.ExtrinsicCalls = false; mexcfg.ResponsivenessChecks = false;