run
クラス: matlab.perftest.TimeExperiment
パッケージ: matlab.perftest
テスト スイートで時間実験を実行
説明
はテスト スイートで時間実験を実行し、results
= run(experiment
,suite
)TimeResult
オブジェクトの配列を返します。results
の各要素は suite
の要素に対応しています。
入力引数
experiment
— 測定値を収集する対象の実験
matlab.perftest.TimeExperiment
インスタンス
測定値を収集する対象の実験。matlab.perftest.TimeExperiment
インスタンスとして指定します。
suite
— テスト スイート
matlab.unittest.Test
配列
テスト スイート。matlab.unittest.Test
配列として指定します。
例
時間実験を実行
現在の作業フォルダーに、さまざまな事前割り当てメソッドを比較するクラスベースのテスト preallocationTest.m を作成します。
classdef preallocationTest < matlab.perftest.TestCase methods(Test) function testOnes(testCase) x = ones(1,1e7); end function testIndexingWithVariable(testCase) id = 1:1e7; x(id) = 1; end function testIndexingOnLHS(testCase) x(1:1e7) = 1; end function testForLoop(testCase) for i=1:1e7 x(i) = 1; end end end end
テスト スイートを作成します。
suite = testsuite('preallocationTest');
固定数のサンプル測定による時間実験を構築して、テストを実行します。
import matlab.perftest.TimeExperiment
numSamples = 10;
experiment = TimeExperiment.withFixedSampleSize(numSamples);
result = run(experiment,suite)
Running preallocationTest .......... .......... .......... .......... Done preallocationTest __________ result = 1x4 TimeResult array with properties: Name Valid Samples TestActivity Totals: 4 Valid, 0 Invalid. 7.1844 seconds testing time.
代替方法
明示的に実験とテスト スイートを作成する必要がない場合は、runperf
を使用できます。
バージョン履歴
R2016a で導入R2019a: パフォーマンス テストの結果は TimeResult
オブジェクトとして返される
run
メソッドは、指定された時間実験の結果を含む matlab.perftest.TimeResult
配列を返します。以前のリリースでは、このメソッドは matlab.unittest.measurement.MeasurementResult
オブジェクトの配列を返します。
MATLAB コマンド
次の MATLAB コマンドに対応するリンクがクリックされました。
コマンドを MATLAB コマンド ウィンドウに入力して実行してください。Web ブラウザーは MATLAB コマンドをサポートしていません。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)