Documentation

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, seeAcceleration

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

让圣arted 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, selectAnalysis>Performance Tools>Performance Advisor

Enable Data Logging for the Model

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

  1. In the model, selectSimulation>Model Configuration Parameters

  2. In the Configuration Parameters dialog box, clickData Import/Exportin the left pane.

  3. Set up signal logging. The model must log at least one signal for Performance Advisor to work. For example, select theStatesorOutputcheck box.

  4. ClickConfigure Signals to Logand 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. ClickOKin 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.

选择验证操作的建议

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。检查您想要运行的选择的for which you want to validate an improvement in performance. Specify validation action for fixes using individual settings for these checks.

  • For all checks。性能顾问自动验证一个我mprovement 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 aTime Outvalue 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, seeEnable Data Logging for the Model

  1. In the model, selectAnalysis>Performance Tools>Performance Advisorto start Performance Advisor.

  2. In the left pane, in the Baseline folder, selectCreate Baseline

  3. In the right pane, underInput Parameters, enter a value in theStop Timefield 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 theCheck to view baseline signals and set their tolerancescheck box to start the Signal Data Inspector after Performance Advisor runs a check. Using the Signal Data Inspector, you can compare signals and adjust tolerance levels.

  5. ClickRun This Check

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

After the baseline has been created, you are 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 asSimulationorSimulation 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 Parameter Description
      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 check box 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 check box 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 check box to have Performance Advisor use the number of blocks of a referenced model to estimate model build time.

  3. To run a single check, clickRun This Checkfrom 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 clickRun Selected Checksfrom the right pane. SelectShow report after runto display the results of the checks after they run.

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

    Note

    TheTime Outsetting 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 formmodel_name\report_#。html

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

Note

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

View and Respond to Results

在您运行检查与性能顾问之后,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.

TheAnalysissection 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)

TheActionsection 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 theTake action based on adviceparameter in theAnalysissection to select how to respond to changes that Performance Advisor suggests.

Value Response
automatically
  • Performance Advisor makes the change for you.

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

  • TheModify Allbutton in theActionsection 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 theModify Allbutton in theActionsection 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 toModify All and Validate

Review Actions

TheActionsection contains a summary of the actions that Performance Advisor took based on theInput Parameterssetting. 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.

Severity Description

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 theReportbox 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 selectShow 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 underFilter checksto 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 thePassedandNot Runcheck boxes.

  • Perform a keyword search using the search box underFilter checks

  • Use the tree of checks underNavigationto 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 settingshas 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 theReportbox, clickSave As

  3. In theSave Asdialog box, navigate to where you want to save the report, and clickSave。Performance Advisor saves the report to the new location.

Related Examples

More About

External Websites

Was this topic helpful?