Code Profile Analyzer
Description
Use the Code Profile Analyzer to analyze execution-time and stack usage profiles produced by software-in-the-loop (SIL) or processor-in-the-loop (PIL) execution of generated code:
View execution times of tasks and functions, visualize the function-call stack at a specific simulation time, and compare execution times from different runs.
View stack usage for tasks and functions and compare values from different runs.
You can also:
Analyze execution-time profiles produced by XCP-based external mode simulations.
Configure code profiling for a model hierarchy.
Identify and analyze performance hotspots in the generated code. This workflow uses the
coder.profile.test.runTests
function.Identify and analyze critical paths in the generated code. This workflow uses the
coder.profile.test.analyzePath
function.
Open the Code Profile Analyzer App
If you are generating code for a Simulink® model, click the SIL/PIL tab. In the Results gallery, under Execution Profiling Results or Stack Profiling Results, click the Code Profile Analyzer button.
If you are generating code for MATLAB® code, terminate the SIL/PIL execution in the Command Window or in the Test Output tab in the MATLAB Coder™ app. The code generator produces a message in the Command Window that contains a link to the execution or stack profiling report. Click that link.
Alternatively, for both Simulink and MATLAB code generation, open the Code Profile Analyzer from the Command Window after
the SIL/PIL execution has been terminated by entering coder.profile.show
or
coder.profile.show(
. profileVariable
)
For Simulink code generation,
is a workspace variable that you specify through the Workspace variable
(profileVariable
CodeExecutionProfileVariable
) or Stack workspace
variable (CodeStackProfileVariable
) configuration
parameter.
For MATLAB code generation, obtain
by using the profileVariable
getCoderExecutionProfile
or getCoderStackProfile
function.
Examples
Related Examples
Version History
Introduced in R2023a