Visualize task scheduling
schedule(, using the
Simulation Data Inspector, helps you to visualize how code was executed on the target
hardware in the last software-in-the-loop (SIL) or processor-in-the-loop (PIL)
Run a simulation with a model that is configured to generate a workspace variable with execution-time measurements.
rtwdemo_sil_topmodel; set_param('rtwdemo_sil_topmodel',... 'CodeExecutionProfiling', 'on'); set_param('rtwdemo_sil_topmodel',... 'SimulationMode', 'software-in-the-loop (SIL)'); set_param('rtwdemo_sil_topmodel',... 'CodeProfilingInstrumentation', 'Detailed'); set_param('rtwdemo_sil_topmodel',... 'CodeProfilingSaveOptions', 'AllData'); simOut = sim('rtwdemo_sil_topmodel');
The simulation generates the variable
in the object
At the end of the simulation, open a code execution report.
Under Profiled Sections of Code, in the
Section column, expand all nodes.
You see profile information for six code sections. For example, the task
[0.1 0] and functions
To visualize how the tasks are scheduled and generated code is executed, run:
The Simulation Data Inspector displays task and simulation time plots.
In each task plot, the Y-axis lists tasks and functions called by each task. From the plots, you can infer the following information:
The order in which tasks run. For example,
If the model is multi-rate, you can see how Simulink® schedules the different rates (a task for each rate).
The time that is required to execute a task or a function, computed as the
difference between the stop and start times. For example, observe that
CounterTypeB takes less time to run than
CounterTypeA. When a task is not running, the Y-axis value of
the plot is
The order in which functions run within a task. For example, in the initialize
counterTypeA_Init function runs before
counterTypeB_Init function. If function calls are nested, you
can see the execution order of the functions.
The last plot shows the simulation time when the tasks and functions are executed.
executionProfile— Variable with profiling data
Variable specified by the Workspace variable configuration parameter, which contains the code execution profiling data. The SIL or PIL simulation generates the variable.
comma-separated pairs of
the argument name and
Value is the corresponding value.
Name must appear inside quotes. You can specify several name and value
pair arguments in any order as
schedule(simOut.executionProfile, 'ShowTasksOnly', false, 'StartSimTime', 0.1, 'StopSimTime', 5.7)
ShowTasksOnly— Turn off function execution display
Control display of function execution plots:
true –– Display task execution only. Do not display
false –– Display task and function execution.
MaxNumPoints— Maximum number of display points
Specify maximum number of points to display.
StartSimTime— Simulation time at start of display
Specify simulation time at the start of the display.
StopSimTime— Simulation time at end of display
Specify simulation time at the end of the display.