Main Content

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.

  1. Configure a SIL simulation model that generates a workspace variable containing stack-usage measurements.

    openExample('ecoder/SILPILVerificationExample', ...
                 supportingFile='SILTopModel.slx')
                 model = bdroot;

  2. 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);
  3. Disable code execution time profiling.

    set_param(model,...
              'CodeExecutionProfiling', 'off');
              set_param(model,...
              'CodeProfilingInstrumentation', 'off');
  4. Enable stack usage profiling.

    set_param(model,...
              'CodeStackProfiling', 'on');
  5. 5. Run the simulation.

    simOut = sim(model);

    The simulation generates the variable stackProfile (default) in the object simOut.

  6. When the simulation is complete, open the code stack profiling report.

    report(simOut.stackProfile)

See Also

Related Topics