Main Content


Display invocations of code sections over execution timeline



timeline(executionProfile) displays invocations of each profiled code section over the execution timeline.


You can use the schedule function to visualize, through the Simulation Data Inspector, task scheduling and the order of function calls.

timeline(executionProfile, 'MaxResizeIncrement', numberOfPoints) specifies the maximum increment by which you:

  • Increase the number of displayed points when you click the zoom-out tool.

  • Move along the timeline plot when you sweep right or left with the pan tool.

Use this command when you want to review large timeline plots quickly.


collapse all

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

openExample('ecoder/SILPILVerificationExample', ...

% Disable Simulink Code Coverage and third-party code coverage analysis
          'CovEnable', 'off');
covSettings = get_param('SILTopModel', 'CodeCoverageSettings');
covSettings.CoverageTool = 'None';
set_param('SILTopModel', 'CodeCoverageSettings', covSettings);

% Configure code execution time profiling
          'CodeExecutionProfiling', 'on');
          'CodeProfilingInstrumentation', 'Detailed');
          'CodeProfilingSaveOptions', 'AllData');
simOut = sim('SILTopModel');

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 and functions CounterTypeA and CounterTypeB.

Display code section invocations.


In the Execution Profile window, you see numbered horizontal bars that represent invocations of the code sections.

For example, the blue bars show when the first section, initialize, is invoked.

To see the first code section, in the first row of the Code Execution Profiling Report, click the icon .

The Code Generation Report displays the function call.

To see what code sections are invoked over a specific time period, use the Start and Range fields of the Execution Profile window. For example, in the Start and Range fields, enter 6e-07 and 2e-07 respectively. Then press Enter.

Between 0.6 μs and 0.8 μs, you see that the task step (code section 4) and the functions CounterTypeA (code section 5) and CounterTypeB (code section 6) are invoked.

On the bottom right of the Execution Profile window, the indicator shows what portion of the execution timeline is being displayed.

Input Arguments

collapse all

When you run a simulation with code execution profiling, the software generates executionProfile as a workspace variable.

Maximum increment for zoom-out and pan tools.

Version History

Introduced in R2013b