Stack Usage Profiling From Command Line
To determine the size of stack memory that is required to run generated code, you can run software-in-the-loop (SIL) or processor-in-the-loop (PIL) simulations that generate stack usage profiles. The profiles that you generate enable you to observe the effect of compiler optimization and data input on stack usage.
This example shows how you can use line commands to produce a stack usage profile for generated code.
Configure a SIL simulation model that generates a workspace variable containing stack-usage measurements.
openExample('ecoder/SILPILVerificationExample', ... supportingFile='SILTopModel.slx') model = bdroot;
Disable Simulink® Coverage™ and third-party code coverage analysis.
set_param(gcs,... 'CovEnable', 'off'); covSettings = get_param(gcs, 'CodeCoverageSettings'); covSettings.CoverageTool = 'None'; set_param(model, 'CodeCoverageSettings', covSettings);
Disable code execution time profiling.
set_param(model,... 'CodeExecutionProfiling', 'off'); set_param(model,... 'CodeProfilingInstrumentation', 'off');
Enable stack usage profiling.
set_param(model,... 'CodeStackProfiling', 'on');
5. Run the simulation.
simOut = sim(model);
The simulation generates the variable
stackProfile
(default) in the objectsimOut
.When the simulation is complete, open the code stack profiling report.
report(simOut.stackProfile)