Main Content

crltest.PerfTestCase.TestCase Class

Namespace: crltest.PerfTestCase

Test case class to validate performance numbers of the generated C/C++ code

Since R2024b

Description

The crltest.PerfTestCase is a test tool to validate performance numbers of the generated C/C++ code from Simulink models using CRL.

This class inherits from sltest.TestCase (Simulink Test) and matlab.unittest.TestCase.

Creation

To create a MATLAB unit testing framework test that you can load, run, and analyze its results in the Test Manager, create a class definition file that inherits from crltest.PerfTestCase. The file contains methods that define the test case.

Methods

expand all

Examples

collapse all

The test case loads a model, sets some variable values, simulates the model, and tests whether the simulation and baseline signals match.

  1. The test case will load a model and sets variable values, configures the CodeExecutionProfiling to on, and CodeProfilingSaveOptions to Alldata, as this is mandatory.

  2. Next configure the simulation mode, so with PIL, you can also set it to SIL depending on your selected target hardware.

  3. Now simulate the model.

  4. Get the simout and CodeExecutionProfileVariable and pass it to logSimulationTime.

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

Version History

Introduced in R2024b