Documentation

Improve Performance of Multirate Model

This example shows how to use Performance Advisor to detect blocks and parameter settings that can reduce performance. It determines the lower limit on sample time that does not produce a CPU overload.

Requirements

This example uses model ex_slrt_perfadv. To open this model, open the subsystem models first:

In ex_slrt_perfadv, the configuration parameter Fixed-step size (fundamental sample time) is set to auto. The sample time is set in the referenced subsystems with a MATLAB variable, Ts. You can change the base sample time by changing the value of Ts.

In addition to the MATLAB® software requirements, the following hardware is required:

  • One Windows® development computer with an Ethernet card

  • One target computer

  • One crossover cable for communication between the development and target computers

Generate Baseline

Before you optimize model ex_slrt_perfadv using Performance Advisor, generate a baseline.

1. Open ex_slrt_perfadv.

2. From the Analysis menu, click Performance Tools >> Performance Advisor.

3. Set Activity to Execute real-time application.

4. Under node Performance Advisor, select all of the Baseline checks except Determine minimum sample time.

Determining the minimum sample time can be a lengthy process for a large model with a long execution time.

5. Select node Baseline, and then click Run selected checks.

For this model, the Real-Time Performance Baseline action fails because running the real-time application produced a CPU overload on the target computer.

6. To remove this condition, increase the sample time to a value greater than the minimum value that does not cause a CPU overload. To find the minimum sample time, select the Determine minimum sample time check box, and then click Run this check.

To avoid the overloads that random variations can cause, set Ts to a value above the lower limit. For example, set it to 0.003 s.

7. In the Command Window, type:

Ts = 0.003

8. Save ex_slrt_perfadv and its reference subsystems.

9. Clear the Determine minimum sample time check box, select the Real-Time Performance Baseline check box, and then click Run this check.

Perform Real-Time Checks

To perform the real-time performance checks on model ex_slrt_perfadv, first create a baseline. Then carry out the following steps using Performance Advisor.

1. Under node Performance Advisor, select all of the top-level Real-Time checks.

If you have a license for Simscape™ or its related products, such as Simscape Driveline™ and Simscape Electronics™, clear those checks. ex_slrt_perfadv contains no Simscape blocks.

2. Select the Real-Time node, and then click Run selected checks.

The model is a multirate model running on a multicore target computer, but it is not configured to use more than one core.

3. In the Solver pane under Additional options, select the check box Allow tasks to execute concurrently on target. Select the same setting for the reference subsystems ex_slrt_perfadv_ref1 and ex_slrt_perfadv_ref2.

4. Save ex_slrt_perfadv and its reference subsystems.

5. Select the Concurrent execution check box, and then click Run this check.

6. To improve the minimum sample time, select the Determine minimum sample time check box, and then click Run this check. The result shows a sample time less than 0.0003 s. To avoid the overloads that random variations can cause, set Ts to a value above the lower limit. For example, set it to 0.001 s.

7. In the Command Window, type:

Ts = 0.001

8. Save ex_slrt_perfadv and its reference subsystems.

Final Validation

The final validation check tests whether model ex_slrt_perfadv works after you performed real-time performance optimizations.

1. Select the Final validation check box, and then click Run this check.

2. To investigate further improvements, see Execution Profiling for Real-Time Applications.

Was this topic helpful?