Using custom code to measure execution time of Simulink subsystems

3 次查看(过去 30 天)
I need to measure the execution time of a subsystem (group of Simulink blocks) which runs as an atomic unit with a specific sampleTime. The measurement will be done on a Real-time embedded target hardware by flashing code generated by Simulink coder.
I am planning to use the custom code block in Simulink coder to add counters to the generated code. By using specific code at entry and exit of the generated code for subsystem, I plan to count number of clock cycles taken to execute the subsystem.
dSpace RTI library has clock counters like
/* Start time measurement.*/
RTLIB_TIC_START();
/*code*/
/* Read the elapsed time period. */
subsystem_exec_time_1 = RTLIB_TIC_READ();
However, I am not sure if I have dSpace libraries at my disposal. My question is how do I write a counter or a function to log elapsed real-time or count number of clock cycles taken for execution? Is there a way that simulink enables such measurements?

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Deployment, Integration, and Supported Hardware 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by