Main Content

Code Execution Profiling From the Command Line

This example shows how you can use line commands to produce execution-time metrics for generated code.

  1. Open SILTopModel, which has two subsystems and is configured to run a software-in-the-loop (SIL) simulation.

    openExample('ecoder/SILPILVerificationExample', ...

  2. Configure code execution time profiling:

    1. Produce execution-time metrics for the task generated from the top model.

      set_param(gcs, 'CodeExecutionProfiling', 'on');

    2. Produce execution-time metrics for functions generated from the subsystems in the model.

      set_param(gcs, 'CodeProfilingInstrumentation', 'coarse');

    3. Save all code profiling data to an object in the base workspace.

                'CodeProfilingSaveOptions', 'AllData');

  3. Disable Simulink® Coverage™ and third-party code coverage analysis.

              'CovEnable', 'off');
    covSettings = get_param(gcs, 'CodeCoverageSettings');
    covSettings.CoverageTool = 'None';
    set_param(gcs, 'CodeCoverageSettings', covSettings);

  4. Run the simulation.

    simOut = sim(gcs);
    The simulation generates the variable executionProfile (default) in the object simOut.

  5. When the simulation is complete, open the code execution report.


  6. To visualize how the tasks are scheduled and the generated code is executed, run:


See Also


Related Topics