Execution-Time Profiling From Command Line
This example shows how you can use line commands to produce execution-time metrics for generated code.
Open
SILTopModel
, which has two subsystems and is configured to run a software-in-the-loop (SIL) simulation.openExample('ecoder/SILPILVerificationExample', ... supportingFile='SILTopModel.slx')
Configure code execution time profiling:
Produce execution-time metrics for the task generated from the top model.
set_param(gcs, 'CodeExecutionProfiling', 'on');
Produce execution-time metrics for functions generated from the subsystems in the model.
set_param(gcs, 'CodeProfilingInstrumentation', 'coarse');
Save all code profiling data to an object in the base workspace.
set_param(gcs,... 'CodeProfilingSaveOptions', 'AllData');
Disable Simulink® Coverage™ and third-party code coverage analysis.
set_param(gcs,... 'CovEnable', 'off'); covSettings = get_param(gcs, 'CodeCoverageSettings'); covSettings.CoverageTool = 'None'; set_param(gcs, 'CodeCoverageSettings', covSettings);
Run the simulation.
The simulation generates the variablesimOut = sim(gcs);
executionProfile
(default) in the objectsimOut
.When the simulation is complete, open the code execution report.
report(simOut.executionProfile)
To visualize how the tasks are scheduled and the generated code is executed, run:
schedule(simOut.executionProfile)