Capture Main Profiling Metrics on Target Hardware

For code execution profiling, to reduce the communication channel bandwidth usage during a software-in-the-loop (SIL) simulation, processor-in-the-loop simulation (PIL), or XCP external mode simulation, you can capture and store only these profiling metrics on the target hardware:

  • Maximum execution time of code section

  • Average execution time of code section

  • Number of calls to code section

At the end of the simulation, Simulink® uploads the metrics from the target hardware to your development computer.

To run a SIL simulation that generates only the main execution-time metrics:

  1. Open the rtwdemo_sil_topmodel model, which has two subsystems CounterTypeA and CounterTypeB.

  2. On the SIL/PIL tab, in the Mode section, select SIL/PIL Simulation Only.

  3. In the Prepare section, specify these settings:

    1. System Under TestTop model

    2. SIL/PIL ModeSoftware-in-the-Loop (SIL)

  4. To measure code execution times for the subsystems:

    1. Click .

    2. In the Configuration Parameters dialog box, select Measure task execution time, which provides execution-time metrics for the task generated from the top model rtwdemo_sil_topmodel.

    3. Set Measure function execution times to Coarse (referenced models and subsystems only), which provides execution-time metrics for the functions generated from the subsystems CounterTypeA and CounterTypeB.

    4. Specify a Workspace variable, for example, executionProfile. If the Data Import/Export > Single simulation output check box is selected, the software creates the variable in the Simulink.SimulationOutput object that you specify.

    5. From the Save options drop-down list, select Metrics only.

    6. Click OK.

  5. In the Prepare section, click Settings. Under Coverage, click the Coverage Collection button off.

  6. In the Run section, click Run SIL/PIL.

The simulation generates the variable executionProfile in the MATLAB® base workspace.

To open the code execution profiling report, in the Profiling window, click the displayed link. In section 2, the report displays the profiled code sections as a flattened list.

The software cannot extract the hierarchy of calls to code sections because this information is not stored on the target hardware.

Overhead filtering is not supported when Save options is set to Metrics only.

See Also

| | |

Related Topics