Analze running time of simulation

3 views (last 30 days)
Max
Max on 23 Aug 2017
Answered: Eeshan Mitra on 25 Aug 2017
Hi,
I'd like to analyze the running time of my simulink model without time for compiling.
My understanding is, if I use
tic
sim(modelName)
toc
the compiling time is measured as well.
Another idea could be the profiler? But then my Simulation gets very slow, so I'm not sure, whether this result is correct.
Has anybody a idea?
Thanks in advance.

Answers (1)

Eeshan Mitra
Eeshan Mitra on 25 Aug 2017
Simulink Profiler adds some overheads in the background to the functions or models being profiled. Since it gives the detailed execution time for each function during simulation, it is the best way to judge the performance of just the "simulation phase".
However, if you do not want to recompile your Simulink model, say for different iterations, consider using the "Fast Restart" option with "tic-toc". Find more information about the "Fast Restart" option in the following link:
Consider the simulation of the model "vdp" with a MATLAB script:
for i=1:4
tic
sim('vdp','FastRestart','on');
toc
end
The first run of the model involves compilation, but not the three subsequent ones. The timing adheres more to the "simulation phase" in the last three simulations.

Community Treasure Hunt

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

Start Hunting!