Main Content


Get execution time in seconds for profiled section of code



ExecutionTimes = NthSectionProfile.ExecutionTimeInSeconds returns a vector of execution times, measured in seconds, for the profiled section of code. Each element of ExecutionTimes contains the difference between the timer reading at the start and the end of the section.

If you set the CodeProfilingSaveOptions parameter to 'SummaryOnly', NthSectionProfile.ExecutionTimeInSeconds returns an empty array. To change that parameter, open the Configuration Parameters dialog box by pressing Ctrl+E, open the Verification pane under Code Generation, and change the Save options parameter to All data.


collapse all

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

set_param('rtwdemo_sil_topmodel', 'CodeExecutionProfiling', 'on');
set_param('rtwdemo_sil_topmodel', 'SimulationMode', 'software-in-the-loop (SIL)');
set_param('rtwdemo_sil_topmodel', 'CodeProfilingInstrumentation', 'on');
set_param('rtwdemo_sil_topmodel', 'CodeProfilingSaveOptions', 'AllData');
The simulation generates the workspace variable executionProfile (default).

At the end of the simulation, get the profile for the seventh code section.

SeventhSectionProfile = executionProfile.Sections(7);

Get vector of execution times for the code section.

time_vector = SeventhSectionProfile.ExecutionTimeInSeconds;

Input Arguments

collapse all

Object generated by the coder.profile.ExecutionTime property Sections.

Output Arguments

collapse all

Execution times, in seconds, for section of code. Returned as a vector.

Introduced in R2013a