Main Content

Improve Simulation Performance Using Performance Advisor

Whatever the level of complexity of your model, you can make systematic changes that improve simulation performance. Performance Advisor checks for configuration settings that slow down your model simulations. It produces a report that lists the suboptimal conditions or settings it finds and suggests better configuration settings where appropriate.

You can use the Performance Advisor to fix some of these suboptimal conditions automatically or you can fix them manually.

Note

Use Performance Advisor on top models. Performance Advisor does not traverse referenced models or library links.

To learn about faster simulation using acceleration modes, see Acceleration.

Performance Advisor Workflow

When the performance of a model is slower than expected, use Performance Advisor to help identify and resolve bottlenecks.

  1. Prepare your model.

  2. Create a baseline to compare measurements against.

  3. Select the checks you want to run.

  4. Run Performance Advisor with the selected checks and see recommended changes.

  5. Make changes to the model. You can either:

    • Automatically apply changes.

    • Generate advice, and review and apply changes manually.

  6. After applying changes, Performance Advisor performs a final validation of the model to see how performance has improved.

    • If the performance improves, the selected checks were successful. The performance check is complete.

    • If the performance is worse than the baseline, Performance Advisor reinstates the previous settings of the model.

  7. Save your model.

Caution

Performance Advisor does not automatically save your model after it makes changes. When you are satisfied with the changes to the model from Performance Advisor, save the model.

Prepare Your Model

Before running checks using Performance Advisor, complete the following steps:

Start Performance Advisor

To get started with Performance Advisor:

  1. Make a backup of the model.

  2. Verify that the model can simulate without error.

  3. Close all applications, including web browsers. Leave only the MATLAB® Command Window, the model you want to analyze, and Performance Advisor running.

    Running other applications can hinder the performance of model simulation and the ability of Performance Advisor to measure accurately.

  4. Open Performance Advisor. In the Simulink® Editor, on the Debug tab, click Performance.

Enable Data Logging for the Model

Make sure the model configuration parameters are set to enable data logging.

  1. In the model, on the Modeling tab, click Model Settings.

  2. In the Configuration Parameters dialog box, in the left pane, select Data Import/Export.

  3. Set up signal logging. The model must log at least one signal for Performance Advisor to work. For example, select the States or Output check box.

  4. Click Configure Signals to Log and select the signals to log.

    Note

    Select only the signals you are most interested in. Minimizing the number of signals to log can help performance. Selecting too many signals can cause Performance Advisor to run for a longer time.

  5. Click OK in the Configuration Parameters dialog box.

  6. Run the model once to make sure that the simulation is successful.

Select How Performance Advisor Applies Advice

Choose from these options to apply advice to the model:

  • Use check parameters. Select the checks for which you want Performance Advisor to automatically apply advice. You can review the remaining checks and apply advice manually.

  • Automatically for all checks. Performance Advisor automatically applies advice to all selected checks.

  • Generate advice only. Review advice for each check and apply changes manually.

Select Validation Actions for the Advice

For the checks you want to run, validate an improvement in simulation time and accuracy by comparing against a baseline measurement. Each validation action requires the model to simulate. Use these validation options as global settings for the checks you select:

  • Use check parameters. From the checks you want to run, select the ones for which you want to validate an improvement in performance. Specify validation action for fixes using individual settings for these checks.

  • For all checks. Performance Advisor automatically validates an improvement in performance for the checks you select.

  • Do not validate. Performance Advisor does not validate an improvement in performance. Instead, you can validate manually. When you select this option and also specify for Performance Advisor to apply advice automatically, a warning appears before Performance Advisor applies changes without validation.

These global settings for validation apply to all checks in the left pane except the Final Validation check. The Final Validation check validates the overall performance improvement in a model after you have applied changes. In case you do not want to validate changes resulting from other check results, you can run the Final Validation check to validate model changes for simulation time and accuracy.

Specify Runtime for Performance Advisor

You can specify a Time Out value in minutes if you want to limit the runtime duration of Performance Advisor. Use this option when running Performance Advisor on models with long simulation times.

If Performance Advisor times out before completing the checks you specify, in the left pane you can see the checks that failed.

Create a Performance Advisor Baseline Measurement

A baseline measurement is a set of simulation measurements that Performance Advisor measures check results against.

Note

Before creating a baseline measurement, set the model configuration parameters to enable data logging. For more information, see Enable Data Logging for the Model.

  1. In the Simulink Toolstrip, on the Debug tab, click Performance.

  2. In the left pane of the Performance Advisor, in the Baseline folder, select Create Baseline.

  3. In the right pane, under Input Parameters, enter a value in the Stop Time field for the baseline.

    When you enter a Stop Time value in Performance Advisor, this overrides the value set in the model. A large stop time can create a simulation that runs longer.

    If you do not enter a value, Performance Advisor uses values from the model. Performance Advisor uses values from the model that are less than 10. Performance Advisor rounds values from the model larger than 10 to 10.

  4. Select the Check to view baseline signals and set their tolerances check box to start the Simulation Data Inspector after Performance Advisor runs a check. Using the Simulation Data Inspector, you can compare signals and adjust tolerance levels.

  5. Click Run This Check.

    When a baseline has been created, a message like the following appears under Analysis:

After the baseline has been created, you can run Performance Advisor checks.

Run Performance Advisor Checks

  1. After you have created a baseline measurement, select checks to run.

    • In the left pane of Performance Advisor, expand a folder, such as Simulation or Simulation Targets, to display checks related to specific tasks.

    • In the folder, select the checks you want to run using the check boxes.

      Tip

      If you are unsure of which checks apply, you can select and run all checks. After you see the results, clear the checks you are not interested in.

  2. Specify input parameters for selected checks. Use one of these methods:

    • Apply global settings to all checks to take action, validate simulation time and validate simulation accuracy.

    • Alternatively, for each check, in the right pane, specify input parameters.

      Input ParameterDescription
      Take action based on advice

      automatically — Allow Performance Advisor to automatically make the change for you.

      manually — Review the change first. Then manually make the change or accept Performance Advisor recommendations.

      Validate and revert changes if time of simulation increases

      Select this option to have Performance Advisor rerun the simulation and verify that the change made based on the advice improves simulation time. If the change does not improve simulation time, Performance Advisor reverts the changes.

      Validate and revert changes if degree of accuracy is greater than tolerance

      Select this option to have Performance Advisor rerun the simulation and verify that, after the change, the model results are still within tolerance. If the result is outside tolerance, Performance Advisor reverts the changes.

      Quick estimation of model build time

      Select this option to have Performance Advisor use the number of blocks of a referenced model to estimate model build time.

  3. To run a single check, click Run This Check from the settings for the check. Performance Advisor displays the results in the right pane.

    You can also select multiple checks from the left pane and click Run Selected Checks from the right pane. Select Show report after run to display the results of the checks after they run.

  4. To limit the run time of Performance Advisor, specify a Time Out value in minutes. Use this option for models with long simulation times. The default setting for this option is 60 minutes.

    Note

    The Time Out setting does not apply to a Quick Scan diagnosis.

Performance Advisor also generates an HTML report of the current check results and actions in a file with a name in the form model_name\report_#.html

To view this report in a separate window, click the Report link in the right pane.

Note

If you rename a system, you must restart Performance Advisor to check that system.

View and Respond to Results

After you run checks with Performance Advisor, the right pane shows the results:

To view the results of a check, in the left pane, select the check you ran. The right pane updates with the results of the check. This pane has two sections.

The Analysis section contains:

  • Information about the check

  • Option to run the simulation

  • Settings to take action based on advice from Performance Advisor

  • Result of the check (Passed, Failed or Warning)

The Action section contains:

  • A setting to manually accept all recommendations for the check

  • Summary of actions taken based on the recommendations for the check

Respond to Results

Use the Take action based on advice parameter in the Analysis section to select how to respond to changes that Performance Advisor suggests.

ValueResponse
automatically
  • Performance Advisor makes the change for you.

  • You can evaluate the changes using the links in the summary table.

  • The Modify All button in the Action section is grayed out since Performance Advisor has already made all recommended changes for you.

manually
  • Performance Advisor does not make the change for you.

  • The links in the summary table show recommendations.

  • Use the Modify All button in the Action section to implement all recommendations after reviewing them. Depending on how you set your validation input parameters before you ran the check, the button label can change to Modify All and Validate.

Review Actions

The Action section contains a summary of the actions that Performance Advisor took based on the Input Parameters setting. If the tool also performed validation actions, this section lists the results in a summary table. If performance has not improved, Performance Advisor reports that it reinstated the model to the settings it had before the check ran.

SeverityDescription

The actions succeeded. The table lists the percentage of improvement.

The actions failed. For example, if Performance Advisor cannot make a recommended change, it flags it as failed. It also flags a check as failed if performance did not improve and reinstates the model to the settings it had before the check ran.

Caution

Performance Advisor does not automatically save your model after it makes changes. When you are satisfied with the changes to the model from Performance Advisor, save the model.

View and Save Performance Advisor Reports

When Performance Advisor runs checks, it generates HTML reports of the results. To view a report, select a folder in the left pane and click the link in the Report box in the right pane.

As you run checks, Performance Advisor updates the reports with the latest information for each check in the folder. Time stamps indicate when checks ran.

In the pane for global settings, when you select Show report after run, Performance Advisor displays a consolidated set of check results in the report.

You can perform these actions using the Performance Advisor report:

  • Use the check boxes under Filter checks to view only the checks with the status that you are interested in viewing. For example, to see only the checks that failed or gave warnings, clear the Passed and Not Run check boxes.

  • Perform a keyword search using the search box under Filter checks.

  • Use the tree of checks under Navigation to jump to the category of checks or a specific check result that interests you.

  • Expand and collapse content in the right pane of the report to view or hide check results.

Some checks have input parameters that you specify in the right pane of Performance Advisor. For example, Identify resource intensive diagnostic settings has several input parameters. When you run checks that have input parameters, Performance Advisor displays the values of the input parameters in the report.

Save Performance Advisor Reports

You can archive a Performance Advisor report by saving it to a new location. Performance Advisor does not update the saved version of a report when you run checks again. Archived reports serve as good points of comparison when you run checks again.

  1. In the left pane of the Performance Advisor window, select the folder of checks for the report you want to save.

  2. In the Report box, click Save As.

  3. In the Save As dialog box, navigate to where you want to save the report, and click Save. Performance Advisor saves the report to the new location.

Related Examples

More About

External Websites