Main Content

getTimingInfo

Class: sltest.testmanager.TestIterationResult
Namespace: sltest.testmanager

Timing execution information for test iteration results

Since R2024a

Syntax

timing = getTimingInfo(tir)
timing = getTimingInfo(tir,phase)

Description

timing = getTimingInfo(tir) returns the timing durations for the execution phases in the test iteration result.

timing = getTimingInfo(tir,phase) returns the duration of the specified execution phase or phases in the test iteration result. To obtain timing durations for more than one phase, enter a comma-separated list.

Note

Multiple-release tests, real-time tests, and RoadRunner tests do not create TimingInfo objects.

Input Arguments

expand all

Test iteration result, specified as a sltest.testmanager.TestIterationResult object.

Example: getTimingInfo(tir)

Test execution phase, specified as a property of the sltest.testmanager.TimingInfo class:

Example: getTimingInfo(tir,"SimulationExecution")

Output Arguments

expand all

Duration of all or the specified test iteration execution phases, returned as an sltest.testmanager.TimingInfo object. The object contains the timing information for a test iteration result.

Examples

expand all

Open the sldemo_absbrake example. Create a test file, test suite, and test case. Remove the default test suite. Set the model to be tested, the values for each iteration, and the iterations.

openExample('sldemo_absbrake');

tf = sltest.testmanager.TestFile('Get Timing Info');
ts = createTestSuite(tf,'Test Suite');
tc = createTestCase(ts,'baseline','Test Case');

tsDel = getTestSuiteByName(tf,'New Test Suite 1');
remove(tsDel);

setProperty(tc,'Model','sldemo_absbrake');

vars = 32:0.5:34;
for k = 1:length(vars)
    % Create test iteration object
    testItr = sltest.testmanager.TestIteration;
    % Set the parameter value for this iteration
    setVariable(testItr,'Name','g','Source',...
       'base workspace','Value',vars(k));
    str = sprintf('Iteration %d',k);
    % Add the iteration object to the test case
    addIteration(tc,testItr,str);
end

Then, run the test and get the test file, test suite, test case, and test iteration results. Get the timing information for the first iteration from the test iteration results.

resultset = run(tf);
tfr = getTestFileResults(resultset);
tsr = getTestSuiteResults(tfr);
tcr = getTestCaseResults(tsr);
tir = getIterationResults(tcr);

timing = getTimingInfo(tir)
itertiming = timing(1)
timing = 

  1×5 TimingInfo array with no properties.

itertiming = 

  TimingInfo with properties:

    SimulationInitialization: 3.8964
         SimulationExecution: 0.0297
       SimulationTermination: 0.2538

To get only the SimulationExecution duration for the first iteration, enter:

timing1 = getTimingInfo(tir,"SimulationExecution");
itertiming1 = timing1(1)
itertiming1 = 

  TimingInfo with properties:

    SimulationExecution: 0.0297

Version History

Introduced in R2024a