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:
Open the rtwdemo_sil_topmodel
model, which has two subsystems
CounterTypeA
and CounterTypeB
.
On the SIL/PIL tab, in the Mode section, select SIL/PIL Simulation Only.
In the Prepare section, specify these settings:
System Under Test — Top
model
SIL/PIL Mode — Software-in-the-Loop
(SIL)
To measure code execution times for the subsystems:
Click .
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
.
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
.
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.
From the Save options drop-down list, select
Metrics only
.
Click OK.
In the Prepare section, click Settings. Under Coverage, click the Coverage Collection button off.
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
.
Measure function execution times | Measure task execution time | Save options | Workspace variable