Main Content


Visualize task scheduling



schedule(executionProfile), 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) simulation.

schedule(executionProfile,Name,Value) uses name-value arguments to control the display of function execution and simulation time.


collapse all

Run a simulation with a model that is configured to generate a workspace variable with execution-time measurements.

          'CodeExecutionProfiling', 'on');
          'SimulationMode', 'software-in-the-loop (SIL)');
          'CodeProfilingInstrumentation', 'Detailed');
          'CodeProfilingSaveOptions', 'AllData');
simOut = sim('rtwdemo_sil_topmodel');

The simulation generates the variable executionProfile (default) in the object simOut.

At the end of the simulation, open a code execution report.


Under Profiled Sections of Code, in the Section column, expand all nodes. You see profile information for six code sections. For example, the task step [0.1 0] and functions CounterTypeA and CounterTypeB.

To visualize how the tasks are scheduled and generated code is executed, run:

Or, from the SIL/PIL tab, open the Results gallery. Under Execution Profiling Results, click Generate Schedule.

The Simulation Data Inspector displays task and simulation time 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 before step.

    If the model is multi-rate, you can see how Simulink® schedules the different rates (a task for each rate).

  • 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 CounterTypeB takes less time to run than CounterTypeA. When a task is not running, the Y-axis value of the plot is NotRunning.

  • The order in which functions run within a task. For example, in the initialize task, counterTypeA_Init function runs before counterTypeB_Init function. If function calls are nested, you can see the execution order of the functions.

  • The last plot shows the simulation time when the tasks and functions are executed.

Input Arguments

collapse all

Variable specified by the Workspace variable configuration parameter, which contains the code execution profiling data. The SIL or PIL simulation generates the variable.

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: schedule(simOut.executionProfile, 'ShowTasksOnly', false, 'StartSimTime', 0.1, 'StopSimTime', 5.7)

Control display of function execution plots:

  • true –– Display task execution only. Do not display function execution.

  • false –– Display task and function execution.

Specify maximum number of points to display.

Specify simulation time at the start of the display.

Specify simulation time at the end of the display.

Introduced in R2021a