Main Content


Automate analysis of task execution times

Since R2024a



resultsSet = coder.profile.test.runTests(modelName) runs software-in-the-loop (SIL) or processor-in-the-loop (PIL) tests of the model by using inputs provided by the model. The function runs in two stages. First, the function runs the tests with only task profiling enabled. Then, the function runs the most demanding tests again with detailed function profiling enabled.

In the first stage, runTests captures the execution times of tasks for the given inputs. In the second stage, runTests identifies how code is executed. For example, it generates a visualization of the function-call stack. runTests does not run detailed profiling in the first stage because instrumentation overhead can be significant and invalidate the acquired time measurements.

The function stores results in the resultsSet object. Use the Code Profile Analyzer to analyze the results.

For information about importing test cases into a model, see Overview of Signal Loading Techniques and Load Input Data for Basic Test Cases.

resultsSet = coder.profile.test.runTests(modelName, TestFile='myTestFile') runs software-in-the-loop (SIL) or processor-in-the-loop (PIL) tests of the model by using test cases in the Simulink® Test™ file myTestFile. As explained previously, the function runs in two stages to reduce the impact of instrumentation overhead.

If the test cases cover system requirements and exercise as many as possible code paths, you can use the function and the Code Profile Analyzer to identify and analyze performance hotspots in the generated code.

resultsSet = coder.profile.test.runTests(..., Name=Value) runs software-in-the-loop (SIL) or processor-in-the-loop (PIL) tests of the model using one or more name-value arguments.


collapse all

You can use coder.profile.test.runTests and the Code Profile Analyzer to identify and analyze performance hotspots in generated code.

Input Arguments

collapse all

Name of model that produces generated code.

Example: runTests('myModel');

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: runTests('myModel', Testfile="myTestFile");

Simulink Test file for model.

Example: runTests('myModel', Testfile="myTestFile");

Type of code profiling metric to analyze for generated code:

  • "time" — Execution-time metrics

  • "stack" — Stack usage metrics

Example: runTests('myModel', CodeMetric="time");

Object that analysis adds results to. If you do not specify an object, the function creates a new object.

Example: runTests('myModel', AppendResultsTo="myNameObject");

Number of most demanding tests to rerun for each task with detailed profiling enabled. Applies to execution-time analysis only.

Example: runTests('myModel', NumTestsForDetailedProfiling=6);

Verbosity for debugging:

  • false — No messages shown during analysis.

  • true — Diagnostic message shown after each step.

Example: runTests('myModel', Verbose=true);

Output Arguments

collapse all

Object that stores test results.

Version History

Introduced in R2024a