MATLAB Answers


Why is the recorded time of a Simulink model by the Profiler so different from that from a stopwatch?

Asked by Pan Zhao on 16 Aug 2017
Latest activity Commented on by Allan Watson on 3 Oct 2019
I have a Simulink model containing several Matlab Functions. When I use the Profiler (enabled through Analysis> Performance Tools > Show profiler report) to analyse the execution time of the model, the profiler always gave a total recorded time of 530~550 seconds. However, the execution time recorded by a stopwatch was definitely below 100 seconds. I cannot understand why there is so much discrepancy between the time given by the Profiler and that by a stopwatch. I am not sure whether this is related to the Matlab Functions in my model.
Any comment is greatly appreciated.


Hi Pan,
The discrepancy here is likely because of the overhead of the Profiler. Because it does more than just time, frequently when running with profiling enabled, the same function(s) can take significantly longer.
Hi aborghes,
Thanks for your reply. But I am still confused. Is the time displayed in Profiler report the real execution time? If so, I believe it should be approximately the same as the time given by a stop watch or the Matlab tic/toc command. However, this is not the case I experienced.
I have the same question/observation. In 2015b, I have been using profiler to investigate some performance issues. When I have profiler active, my entire real-world time is about 3 minutes. But profiler Total Time (using both -Timer performance and -Timer cpu) is listed as 7500 seconds. Even though profiler does slow things down, this is a factor of about 37.5 from reported time to clock time. I don't think it's even multithreading factors, because I don't have that many cores.
That said, I can use the values to measure relative improvements, even if the absolute numbers don't make sense.

Sign in to comment.

1 Answer

Answer by Aveek Podder on 23 Aug 2017

I understand that you want to measure the real execution time of your Simulink model. Profiler is an overhead function which run in the background and it collects the execution time. This make the system slow and thus the profile time is more.
"tic-toc" gives the actual execution time of the Simulation.


Sign in to comment.