Main Content

Execution Profiling for Generated Code

Use code execution 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:

  1. With the Simulink® model, design and optimize your algorithm.

  2. Configure the model for code execution profiling, and generate code.

  3. Execute generated code on target. 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.

    • Perform real-time execution with Simulink Real-Time™ or a target support package.

  4. 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.

  5. If required, refine the model and return to step 2.

To find information about code execution profiling with Simulink products, use the following table.

Target Execution Feature Type of Profiling Relevant Products See
Development computer Model configured for concurrent execution Execution time Simulink Coder™
Development computer Software-in-the-loop (SIL) Execution time Embedded Coder®
Embedded hardware or instruction set simulator Processor-in-the-loop (PIL) Execution time Embedded Coder
Simulink Real-Time Real-time executionExecution time Simulink Coder, Simulink Real-Time

Related Topics