前言
为了弄清楚simulink程序里各个模块的单步的耗时,了解到可以使用profiler查看。
正文
使用以下语句,可以打开simulink profiler,再执行仿真后,就有各个模块的各个phase的执行时间的报告了。
set_param(‘mymodel’, ‘Profile’, ‘on’);

结果是大串英文,看不懂。在该文件里找到了help,翻译如下:
※summary legend
Total recorded time:总记录时间
Total time for simulating the model. 跑仿真模型的总时间。
Number of Block Methods:模块(包括如scope在内的各种)的数量:
Total number of methods called by individual blocks in the model 模型中单个块调用的总数
Number of Internal Methods :内部方法的数量:
Total number of internal Simulink methods called by the model. 模型调用的内部Simulink方法的总数。
Number of Model Methods:模型方法的数量
Number of methods called by the model. 模型调用的方法数。
Number of Nonvirtual Subsystem Methods:非虚拟子系统方法的数量:
Number of methods called by any nonvirtual subsystems in the model 模型中任何非虚拟子系统调用的方法数
Clock precision:时钟精度
Precision of the profiler’s time measurement.
※Function List Legend
Time:时间
Time spent in this function, including all child functions called.
在此函数中花费的时间,包括调用的所有子函数。
Calls:调用
Number of times this function was called.调用此函数的次数。
Time/call: 每次调用花费的时间
Time spent per call.每次调用花费的时间
Self time:自我时间
Total time spent in this function, not including any calls to child functions.此函数花费的总时间,不包括对子函数的任何调用。
Location:位置
Link to the location of the block in your model. Use the link "Clear Highlighted Blocks"at the top of the page to unhilite all blocks. (Note: you must use the MATLAB Help browser to use these hyperlinks).链接到块在模型中的位置。使用页面顶部的链接“清除高亮显示的块”可以取消选中所有块。(注意:必须使用MATLAB帮助浏览器才能使用这些超链接)
Note: In accelerated mode, individual blocks will not show up in the profiler, unless they are executed internally in Simulink (e.g. a scope runs in Simulink instead of the generated code). Rerun in normal mode to get a more detailed analysis of the simulation.
注意:在加速模式下,除非在Simulink中内部执行,否则单个块不会显示在探查器中(例如,作用域在Simulink而不是生成的代码中运行)。在正常模式下重新运行,以获得更详细的模拟分析。
综合以上信息,“Time/call” 大概是我需要关注的。
※Model execution pseudocode 模型执行伪代码

文章介绍了如何使用Simulink的Profiler来查看各模块在仿真过程中的执行时间。Profiler提供了总记录时间、模块方法、内部方法等统计信息,并强调了Time/call作为关注点,用于衡量函数每次调用的时间消耗。在加速模式下,部分详细信息可能无法显示,需要在正常模式下运行获取更详尽的分析。
650





