How can I get the code execution tome of the model in simulink? (for the code generation of the C2000 processors)

I want to know what is the execution time of my model in simulink. I need to set a proper sampling time for the code generation for C2000 processors.
Thanks.

댓글 수: 2

To determine the execution time of a model you can use the following command:
tic
sim('myModel');
toc
or you can also use Simulink profiler .
Hope that helps.
tic and toc are used together to measure the elapsed time, not the execution time.

댓글을 달려면 로그인하십시오.

 채택된 답변

Hi JIANWEI,
Here are 2 techniques that will help you profile the execution time of the generated code on the TI C2000 processors:
  1. In R2017a, we introduced multitasking profiling, which will allow you to measure and visualize execution time and preemptions for the different synchronous rates in your model. Check the Real-Time Code Execution Profiling Example to learn more about this technique.
  2. In PIL mode, you can enable profiling and measure the execution time of your generated code. The Code Verification and Validation with PIL Example will show you how to run in PIL on the TI C2000 devices, while the "Code Verification and Validation with PIL" chapter of the documentation will explain you how to enable profiling with PIL.
I hope this helps,
Good luck!
Antonin.

댓글 수: 5

Hi Antonin,
This really helps. Thank you very much.
Jianwei
Hi Antonin, Regarding the 'Code Execution Profiling Report'
1) How to understand the term 'Average Turnaround Time'? what is the relationship between this time and code execution time?
2) How to set the value for 'Number of profiling samples to collect'? How does this affect the measured execution time? I tried to find some useful information on this but I did not find them. Can you please provide more information?
3) For the same operation of the code, the obtained execution time should be smaller than the sample time. Am I right?
Thank you very much.
Jianwei
Hi JIANWEI,
1) The multitasking profiling tool will measure tasks that may be preempted. The "Average Turnaround Time" includes the code execution time and the preemption time while "code execution time" only includes the code execution time in this particular task. If there is no preemption, the two measurements should be equal.
2) In the configuration parameters of the model, go to "Hardware Implementation". You should have a TI C2000 board selected for "Hardware Board". In the "Target Hardware Resources" go to "Execution profiling", this is where you can find the "Number of profiling samples to collect". This will decide how much memory you want to allocate on the Hardware to collect samples for profiling. Profiling starts on the Hardware when the program starts and stops when this buffer is full, so the bigger the buffer is, the more profiling data you will have. Increasing the "Number of profiling samples to collect" will increase the buffer and allow you to measure events that may not be happening at startup.
3) If the execution time is larger than the sample time, you are in an overrun situation which is not good. You want to keep the execution time below the sample time to make sure that you are fully in control of the behavior of your program. For your information, in case of an overrun, our scheduler will skip the next instance of the task. For example if a task is scheduled at 50µs and constantly takes 65µs to execute, you will see this task scheduled at 100µs as we will always skip one execution every cycle. If the task takes 125µs to execute, it will run every 150µs as we will skip twice every cycle, and so on... Better to make sure that you are in control of the sample time and you don't have overruns.
I hope it helps,
Good luck,
Antonin.
Hi Antonin,
Thank you very much. These are quite helpful.
Jianwei
Hi Antonin,
1. Is the execution profile is for code running in hardware or for simulation in simulink environment?
2. If the execution profile is collected from hardware, through which interface (serial, can etc...) the data is collected from hardware.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Dear Antonin,
We have tried to measure and visualize execution time and preemptions for the different synchronous rates in our model following your recommendation. However, the following error arose while compiling:
*The parameter ExecutionProfileBufferLen is not defined for selected hardware board.
We are trying to measure the execution times of the F28335 board. Could you clarify us which could be the root of the error we are having?
Thank you in advance and best regards,
Manex.

카테고리

도움말 센터File Exchange에서 Code Generation에 대해 자세히 알아보기

질문:

2017년 2월 24일

댓글:

BD
2017년 12월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by