Main Content

ExecutionTimeInSeconds

Get execution time in seconds for profiled section of code (MATLAB code generation)

Description

example

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.

Examples

collapse all

Copy MATLAB® code to your working folder.

src_dir = ...
    fullfile(docroot,'toolbox','coder','examples','kalman');

copyfile(fullfile(src_dir,'kalman01.m'), '.')
copyfile(fullfile(src_dir,'test01_ui.m'), '.')
copyfile(fullfile(src_dir,'plot_trajectory.m'), '.')
copyfile(fullfile(src_dir,'position.mat'), '.')

Set up and run a SIL execution.

config = coder.config('lib');
config.GenerateReport = true;

config.VerificationMode = 'SIL';
config.CodeExecutionProfiling = true;

codegen('-config', config, '-args', {zeros(2,1)}, 'kalman01');

coder.runTest('test01_ui', ['kalman01_sil.' mexext]);

At end of the execution, you see the following message.

To terminate execution: clear kalman01_sil
Execution profiling report available after termination.

Click the link clear kalman01_sil.

### Stopping SIL execution for 'kalman01'
    Execution profiling report: report(getCoderExecutionProfile('kalman01'))

Create a workspace variable that holds execution time data.

executionProfile=getCoderExecutionProfile('kalman01');

Get the profile for the second code section.

SecondSectionProfile = executionProfile.Sections(2);

Get vector of execution times for the code section.

time_vector = SecondSectionProfile.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