Main Content

Time

コード セクションのシミュレーション時間を取得

説明

SimTime = NthSectionProfile.Time は、コード セクションの実行時間計測値に対応するシミュレーション時間ベクトルを返します。

すべて折りたたむ

SIL シミュレーション、PIL シミュレーション、または XCP ベースのエクスターナル モード シミュレーションを実行できるモデル myModel.slx がある場合、実行時間測定値を格納するワークスペース変数を生成するようにモデルを構成できます。

set_param('myModel', 'CodeExecutionProfiling', 'on');
set_param('myModel', 'CodeProfilingInstrumentation', 'detailed');
set_param('myModel', 'CodeProfilingSaveOptions', 'AllData');
コマンド sim('myModel') を実行すると、シミュレーションで変数 executionProfile (既定) が生成されます。シミュレーションの終了時に、コード セクションのプロファイルを取得します。次に例を示します。
seventhSectionProfile = executionProfile.Sections(7);
次に、コード セクションのシミュレーション時間を表すベクトルを取得します。
simulationTimeVector = seventhSectionProfile.Time;

この例では、SIL モデル シミュレーションを実行します。モデルで実行時間測定値を格納するワークスペース変数が生成されます。

openExample('ecoder/SILPILVerificationExample', ...
             supportingFile='SILTopModel.slx')

% Disable Simulink Code Coverage and third-party code coverage analysis
set_param('SILTopModel',...
          'CovEnable', 'off');
covSettings = get_param('SILTopModel', 'CodeCoverageSettings');
covSettings.CoverageTool = 'None';
set_param('SILTopModel', 'CodeCoverageSettings', covSettings);

% Configure code execution time profiling
set_param('SILTopModel',...
          'CodeExecutionProfiling', 'on');
set_param('SILTopModel',...
          'CodeProfilingInstrumentation', 'detailed');
set_param('SILTopModel',...
          'CodeProfilingSaveOptions', 'AllData');
simOut = sim('SILTopModel');
シミュレーションのオブジェクト simOut で変数 executionProfile (既定) が生成されます。

シミュレーションの終了時に、6 番目のコード セクションのプロファイルを取得します。

sixthSectionProfile = simOut.executionProfile.Sections(6);

コード セクションのシミュレーション時間を表すベクトルを取得します。

simulationTimeVector = sixthSectionProfile.Time;

入力引数

すべて折りたたむ

coder.profile.ExecutionTime プロパティ Sections で生成されるオブジェクト。

出力引数

すべて折りたたむ

コードのセクションのシミュレーション時間 (秒単位)。ベクトルとして返されます。

バージョン履歴

R2013a で導入