Stateflow® uses Just-In-Time (JIT) compilation mode to improve model update performance of most charts. Stateflow applies JIT mode to charts that qualify. For a chart in JIT mode, Stateflow generates an execution engine in memory for simulation. For these charts, Stateflow does not generate C code or a MEX file to simulate the chart. JIT mode provides the best performance during the compilation of a model.
Some charts do not qualify for JIT mode, such as charts with:
Debugging breakpoints set
Custom C code symbols
Model Coverage in Simulink® Verification and Validation™
For charts that do not qualify for JIT mode, Stateflow generates C code with debugging support. The C code is built into an executable file that is used during simulation.
To gain optimal performance for charts that do not qualify for JIT mode, turn off debugging using this command.
sfc('coder_options', 'forceDebugOff', 1);
After you run this command, these charts do not have debugging, animation, or run-time error checking.
To simulate your model more quickly, open the Model Configuration Parameters dialog box. In the All Parameters tab, clear the check boxes for these parameters.
Echo expressions without semicolons — Clear this check box to disable run-time output in the MATLAB® Command Window, such as actions that do not terminate with a semicolon.
Ensure responsiveness— Clear this check box to disable ability to break out of long-running execution using Ctrl+C.
During model simulation, any open charts with animation enabled take longer to simulate. If you keep all charts closed, you can speed up the simulation.
During model simulation, any open Scope blocks continuously update their display. If you keep all Scope blocks closed, you can speed up the simulation. After the simulation ends, you can open the Scope blocks to view the results.
If your model contains multiple charts that do not use JIT mode and contain the same elements, you might generate multiple copies of identical simulation code. By using library charts, you can minimize the number of copies of identical simulation code. For example, using five library charts reduces the number of identical copies from five down to one.
For more information about using library charts, see Create Specialized Chart Libraries for Large-Scale Modeling.