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) or processor-in-the-loop (PIL) run.executionProfile
)
schedule(
uses name-value arguments to control the display of function execution and execution
time.executionProfile
,Name,Value
)
Examples
Visualize Task Scheduling
For a MATLAB® function, perform a software-in-the-loop execution that generates execution-time measurements and then use the data to visualize task scheduling.
Open the EuclideanDistanceExample
example to obtain the files for
this tutorial. For more information about this example, see Generate C Code at the Command Line.
openExample('coder/EuclideanDistanceExample')
To make the MATLAB code suitable for code generation, in euclidean.m
,
replace:
idx(1)=1; idx(2)=1; distance(1)=norm(x-cb(:,1)); distance(2)=norm(x-cb(:,1));
with:
idx = ones(1,2); distance = ones(1,2)*norm(x-cb(:,1));
Configure SIL execution with profiling.
config = coder.config('lib'); config.GenerateReport = true; config.VerificationMode = 'SIL'; config.CodeExecutionProfiling = true; config.CodeProfilingInstrumentation = true; config.EnableOpenMP = false;
In the current folder, create test_example.m
, a MATLAB script that calls the compiled function twice.
[y_min,y_max,idx,distance] = euclidean(x,cb); [y_min2,y_max2,idx2,distance2] = euclidean(x*2,cb*2);
Generate library code for the euclidean
MATLAB function and the SIL interface and start the SIL execution.
load euclidean_data.mat codegen -report -config config euclidean -args {x, cb} -test test_example
Code generation successful: View report Running test file: 'test' with MEX function 'euclidean_sil.mexw64'. ### Starting SIL execution for 'euclidean' To terminate execution: clear euclidean_sil Execution profiling data is available for viewing. Go to Simulation Data Inspector. Execution profiling report available after termination. ...
Terminate the SIL execution process by clicking the link clear
euclidean_sil
.
### Application stopped
### Stopping SIL execution for 'euclidean'
Execution profiling report: report(getCoderExecutionProfile('euclidean'))
Create a workspace variable that holds the execution time data.
executionProfile=getCoderExecutionProfile('euclidean');
To open the code execution report, run:
report(executionProfile)
To visualize how the tasks are scheduled and generated code is executed, run:
schedule(executionProfile)
The Simulation Data Inspector displays these 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,
initialize
runs beforeeuclidean
.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 the initial calls to
fabs
andsqrt
take more time to run than subsequent calls to the same functions. 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
euclidean
task, there are three calls tofabs
before each call tosqrt
.If function calls are nested, you can see the call stack for the functions.
The simulation time plot displays the call number for the
euclidean
function. In this example, there are two calls to
euclidean
.
Input Arguments
executionProfile
— Variable with profiling data
object
Workspace variable that contains the code execution profiling data generated by the SIL or PIL execution.
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(executionProfile, 'ShowTasksOnly', false, 'StartSimTime', 2,
'StopSimTime', 4)
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
— Execution time at start of display
float
Specify execution time at the start of the display.
StopSimTime
— Execution time at end of display
float
Specify execution time at the end of the display.
Version History
Introduced in R2021b
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 (한국어)