Main Content


(To be removed) Display invocations of code sections over execution timeline

timeline will be removed in a future release. Use schedule instead. (since R2021a) For more information, see Version History.



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

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

collapse all

R2024a: Warns

The timeline function issues a warning that it will be removed in a future release. Use the schedule function to visualize task scheduling in the Simulation Data Inspector.