Computational Time Analysis in Simulink

Hello everyone,
i need to generates plot about the time that is necessary to the simulation environment in order to do all the calculations in every single step time.
The result i expect is a plot where on Y there is the real time needed for each step time and in X there is the simulation time.
Is there Some one know how to realize in "automatic" way through a script this kind of anaysis?
Maybe there is a way to use tic-toc sequence but i have only derived the real time needed for an entire simulation...
Thanks in advance.

Answers (1)

There is no meaningful solution for continuous time models. Continuous time models use ode solvers that can reject steps in order to stay within integration tolerance, so the required time can vary depending on the initial conditions and the prediction model. The prediction model can take variable step sizes so the time per change of the independent variable can change during execution.
For discrete time models if rapid acceleration is turned on then Simulink divides the work up into tasks according to required rate, and executes some tasks less often and executes some tasks in parallel. The portions of the model that are grouped together into tasks are not necessarily functionally related, they might just happen to be running at the same rate.
At the best of times there are items that have to be executed for every minor time step and items that are every major time step, so the work over time depends on where you are in major vs minor steps.

3 Comments

Firs of all, thank for the fast response!!
Referring to the statement:
"There is no meaningful solution for continuous time models. Continuous time models use ode solvers that can reject steps in order to stay within integration tolerance, so the required time can vary depending on the initial conditions and the prediction model. The prediction model can take variable step sizes so the time per change of the independent variable can change during execution."
This is exactly the reason why i want to monitor the computational time. To evaluated from a graphical point of view, which configuration are more onerous in terms of computational effort.
Seems strange that is not possible to collect this information as a time series for example. Also because if i use a for loop to to simulate a priori-fixed and limited number of step of a recursive model, i could insert tic-toc sequence that is evaluated at every increments of the loop index (i++ to be short). At end of the for loop there is a collection of tic-toc differences that is the computation time along the limited number of recursive steps.
Anyway, thank a lot for your time!!
Have you considered using Performance Advisor or the Profiler?
Thanks for the response!
The profiler is the tool i usually exploit.
Tipical report from the profiler is a sort of "reverse" bar graph where is shown the percentage of usage of each function/block with respect of the totasl number of call along the entire simulation. The problem is that this is an information equivalent to mean value of the comp.time because i cant observe in which point of the simulation there is an increasing complecity due to some change...
As i writes above, in matlab script i am able to derive the expected result if the system equation can be inserted in a for loop, but in simulink i have not found any solution up to now.
I will look at the Advisor more in detail anyway!
Thanks for your time!!

Sign in to comment.

Categories

Products

Release

R2018b

Asked:

on 27 May 2022

Commented:

on 27 May 2022

Community Treasure Hunt

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

Start Hunting!