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(默认值)。

在仿真结束时,获得第六个代码节的探查信息。

sixthSectionProfile = simOut.executionProfile.Sections(6);

获取表示该代码节的仿真时间的向量。

simulationTimeVector = sixthSectionProfile.Time;

输入参数

全部折叠

coder.profile.ExecutionTime 属性 Sections 生成的对象。

输出参量

全部折叠

代码节的仿真时间,以秒为单位。以向量形式返回。

版本历史记录

在 R2013a 中推出