Execution-Time Profiling for Generated Code
Use execution-time profiling to:
Determine whether the generated code meets execution time requirements for real-time deployment on your target hardware.
Identify code sections that require execution speed improvements.
The following tasks represent a general workflow that uses code execution profiling:
With the Simulink® model, design and optimize your algorithm.
Configure the model for code execution profiling, and generate code.
Execute generated code on target hardware. For example, you can:
Run a software-in-the-loop (SIL) simulation on your development computer.
Run a processor-in-the-loop (PIL) simulation using a target support package or custom PIL target.
Run an XCP-based external mode simulation on your development computer or on custom hardware.
Perform real-time execution with Simulink Real-Time™ or a target support package.
Analyze execution speed through code execution profiling plots and reports. For example, check that the algorithm code satisfies execution time requirements for real-time deployment:
If the algorithm code easily meets the requirements, consider enhancing your algorithm to exploit available processing power.
If the code cannot be executed in real time, look for ways to reduce execution time.
Identify the tasks that require the most time. For these tasks, investigate whether trade-offs between functionality and speed are possible.
If your target is a multicore processor, distribute the execution of algorithm code across available cores.
If required, refine the model and return to step 2.
Create an aggregate of execution-time profiles by running model simulations for your test cases. Use the Code Profile Analyzer to process the aggregate. For each task, identify the longest execution time and corresponding test case.
When you have a sufficient number of test cases, you can use
coder.profile.test.runTests
to automate the analysis of task execution times.
To find information about code execution profiling with Simulink products, use the following table.
Type of Execution | Target | Relevant Products | See |
---|---|---|---|
Software-in-the-loop (SIL) | Development computer | Embedded Coder® | |
Processor-in-the-loop (PIL) | Embedded hardware or instruction set simulator | Embedded Coder | |
XCP external mode | Development computer or custom hardware | Embedded Coder | |
Real-time execution | Simulink Real-Time | Simulink Coder™, Simulink Real-Time |
|