schedule
Description
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), processor-in-the-loop (PIL), or XCP-based
external mode simulation.executionProfile
)
schedule(
uses name-value arguments to control the display of function execution and simulation
time.executionProfile
,Name,Value
)
Examples
Visualize Task Scheduling in SIL Simulation
This example uses a SIL simulation to show how you can visualize task scheduling. For an example that uses an XCP external mode simulation, see Visualize Task Scheduling in XCP External Mode Simulation.
Run a SIL simulation with a model that is configured to generate a workspace variable with execution-time measurements.
openExample('ecoder/SILPILVerificationExample', ... supportingFile='SILTopModel.slx') % Disable Simulink Code Coverage and third-party code coverage analysis set_param('SILTopModel',... 'CovEnable', 'off'); covSettings = get_param('SILTopModel', 'CodeCoverageSettings'); covSettings.CoverageTool = 'None'; set_param('SILTopModel', 'CodeCoverageSettings', covSettings); % Configure code execution time profiling set_param('SILTopModel',... 'CodeExecutionProfiling', 'on'); set_param('SILTopModel',... 'CodeProfilingInstrumentation', 'Detailed'); set_param('SILTopModel',... 'CodeProfilingSaveOptions', 'AllData'); simOut = sim('SILTopModel');
The simulation generates the variable executionProfile
(default)
in the object simOut
.
At the end of the SIL simulation, open the Code Profile Analyzer:
Click the SIL/PIL tab.
In the Results gallery, under Execution Profiling Results, click Code Profile Analyser.
In the Analysis section, click Function
Execution. You see execution-time metrics for six code sections, for
example, the step [0.1 0]
task and the
CounterTypeA
and CounterTypeB
functions.
To visualize how the tasks are scheduled and generated code is executed, in the Results section, click Generate Schedule. Or, in the Command Window, enter:
schedule(simOut.executionProfile)
The Simulation Data Inspector displays task and simulation time plots.
In each task plot, the Y-axis lists tasks and functions executed. From the plots, you can infer the following information:
The order in which tasks run.
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 thanCounterTypeA
. When a task is not running, the Y-axis value of the plot isNotRunning
.The order in which functions run within a task. For example, in the initialize task,
counterTypeA_Init
function runs beforecounterTypeB_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.
Input Arguments
executionProfile
— Variable with profiling data
object
Variable specified by the Workspace variable configuration parameter, which contains the code execution profiling data. The SIL or PIL simulation generates the variable.
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN
, where Name
is
the argument name and Value
is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Before R2021a, use commas to separate each name and value, and enclose
Name
in quotes.
Example: schedule(simOut.executionProfile, 'ShowTasksOnly', false,
'StartSimTime', 0.1, 'StopSimTime', 5.7)
ShowTasksOnly
— Turn off function execution display
false (default) | true
Control display of function execution plots:
true
–– Display task execution only. Do not display function execution.false
–– Display task and function execution.
MaxNumPoints
— Maximum number of display points
integer
Specify maximum number of points to display.
StartSimTime
— Simulation time at start of display
float
Specify simulation time at the start of the display.
StopSimTime
— Simulation time at end of display
float
Specify simulation time at the end of the display.
Version History
Introduced in R2021a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)