ExecutionTimeInTicks - Get execution times in timer ticks for profiled section of code - MATLAB (original) (raw)
Main Content
Get execution times in timer ticks for profiled section of code
Syntax
Description
[ExecutionTimes](#mw%5F96cef7d4-39da-4768-aa03-8e9117f0f059) = [NthSectionProfile](#mw%5F7331e07b-48d0-4884-9b7d-f627c8904fab).ExecutionTimeInTicks
returns a vector of execution times, measured in timer ticks, 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. The data type of the arrays is the same as the data type of the timer used on the target, which allows you to infer the maximum range of the timer measurements.
If you set the CodeProfilingSaveOptions
parameter to'SummaryOnly'
,_`NthSectionProfile`_.ExecutionTimeInTicks
returns an empty array. To change that parameter, open the Configuration Parameters dialog box by pressing Ctrl+E, open the pane under , and change the Save options parameter toAll data
.
You can calculate the execution time in seconds using the formula ExecutionTimeInSecs=ExecutionTimeInTicks/TimerTicksPerSecond
Examples
If you have a model myModel.slx
that can run a SIL, PIL, or XCP-based external mode simulation, you can configure the model to generate a workspace variable that contains execution time measurements.
set_param('myModel', 'CodeExecutionProfiling', 'on'); set_param('myModel', 'CodeProfilingInstrumentation', 'detailed'); set_param('myModel', 'CodeProfilingSaveOptions', 'AllData');
When you run the command sim('myModel')
, the simulation generates the variable executionProfile
(default). At the end of the simulation, get the profile for a code section. For example:
seventhSectionProfile = executionProfile.Sections(7);
Then, get the vector of execution times (measured in timer ticks) for the code section.
time_vector = seventhSectionProfile.ExecutionTimeInTicks;
In this example, run a SIL model simulation where the model generates a workspace variable that contains execution time measurements.
openExample('ecoder/SILPILVerificationExample', ... supportingFile='SILTopModel.slx')
% Disable Simulink Code Coverage and third-party code coverage analysis set_param('SILTopModel',... 'CovEnable', 'off'); covSettings = get_param('SILTopModel', 'CodeCoverageSettings'); covSettings.CoverageTool = 'None'; set_param('SILTopModel', 'CodeCoverageSettings', covSettings);
% Configure code execution time profiling set_param('SILTopModel',... 'CodeExecutionProfiling', 'on'); set_param('SILTopModel',... 'CodeProfilingInstrumentation', 'detailed'); set_param('SILTopModel',... 'CodeProfilingSaveOptions', 'AllData'); simOut = sim('SILTopModel');
The simulation generates the variable executionProfile
(default) in the object simOut
.
At the end of the simulation, get the profile for the sixth code section.
sixthSectionProfile = simOut.executionProfile.Sections(6);
Get the vector of execution times (measured in timer ticks) for the code section.
time_vector = sixthSectionProfile.ExecutionTimeInTicks;
Input Arguments
The NthSectionProfile
is acoder.profile.ExecutionTimeSection
object generated by thecoder.profile.ExecutionTime
propertySections
.
Example: NthSectionProfile
Output Arguments
The SelfExecutionTimes
is a vector of execution times, in timer ticks, for profiled section of code.
Version History
Introduced in R2012b