Main Content

Run Tests Using Parallel Execution

Running tests in parallel can speed up execution and decrease the amount of time it takes to get test results. If you have a Parallel Computing Toolbox™ license, you can execute tests in parallel on your local machine or cluster. If you have a MATLAB® Parallel Server™ license, you can execute tests in parallel on a remote cluster, such as in the cloud.

When Do Tests Benefit from Using Parallel Execution?

In general, parallel execution can help reduce test execution time if you have

  • A complex Simulink® model that takes a long time to simulate

  • Numerous long-running tests, such as iterations

Use Parallel Execution

To run tests in parallel:

  1. Set up and open a parallel pool on the desired cluster, or set the desired cluster as the default. If you have a Parallel Computing Toolbox license, see Discover Clusters and Use Cluster Profiles (Parallel Computing Toolbox). If you have a MATLAB Parallel Server license, see Running Code on Clusters and Clouds (MATLAB Parallel Server). If you do not set your default cluster or have a parallel pool open, the Test Manager uses its default cluster, which is on the local machine.

  2. Open the Test Manager.

  3. On the Test Manager toolstrip, click the Parallel button.

  4. Run a test file. The test file executes using parallel pool.

    Note

    Baseline, equivalence, custom and assessments criteria evaluation occurs on the host MATLAB and not on the parallel MATLAB workers. Before parallel test execution begins, the base workspace variables from the host MATLAB are transferred to the base workspaces of the parallel MATLAB workers. However, after parallel test execution completes, the base workspace variables are not transferred back to the host MATLAB.

  5. To turn off parallel execution, click the Parallel button to toggle it off.

Starting a parallel pool can take time, which would slow down test execution. To reduce time:

  • Make sure that the parallel pool is already running before you run a test. By default, the parallel pool shuts down after being idle for a specified number of minutes. To change the setting, see Specify Your Parallel Preferences (Parallel Computing Toolbox).

  • Load Simulink on all the parallel pool workers.

See Also

Related Topics