Main Content

logsimulationtime

Log the execution time of simulation

Since R2024b

Description

logsimulationtime(testCase,'CodeExecutionProfileVariable'varName) logs the total execution time of the sections in the code execution profile associated with a variable inside simulation output.

Note

To use the method logsimulationtime, the model should be configured with CodeExecutionProfiling to on and CodeProfilingSaveOptions to Alldata.

[modelname,modelhandle,modelpath] = loadSystem(___,Name,Value) loads the model and test case with additional options specified by one or more Name,Value pairs.

example

Input Arguments

expand all

Instance of the test case, specified as an crltest.PerfTestCase object.

A Simulink.SimulationOutput object containing the simulation results, which must include a code execution profile variable.

Name-Value Arguments

Name of the variable in simulation output that contains coder.profile.ExecutionTime object representing the code execution profile.

Examples

expand all

classdef tLogPerfomence < crltest.PerfTestCase
    methods (Test)
        function checkCRL(testCase)
            
            model = 'testModelDiscreteFir';
            testCase.loadSystem(model)
            
            set_param(model,'CodeExecutionProfiling', 'on');
            set_param(model,'CodeProfilingSaveOptions','Alldata');
            
            set_param(model,'SimulationMode','processor-in-the-loop (pil)');
            
            % Run a simulation that generates a code execution profile
            simOut = testCase.simulate(model);
            
            % Log the total execution time of the simulation
            varName = get_param(model,'CodeExecutionProfileVariable');
            testCase.logSimulationTime(simOut,'CodeExecutionProfileVariable',varName)
        end
    end
end
result = runperf('tLogPerformance')
result.sampleSummary

Version History

Introduced in R2024b