MATLAB: What is the meaning of “Other lines & overhead” in the profiler

MATLAB

When I run the profiler, it tells me that a lot of time is being spent on "Other lines & overhead" of the code. What does this mean?

Best Answer

Overhead can come from two main places. One is what we call "first time costs" which includes parsing and optimizing program files the first time they are called. The second is from function call overhead.
To factor out the effects of first time costs a program should be run a few times (3-4) in the profiler before looking at the data. There isn't much users can do to reduce first time costs in the current system. Function call overhead can only be reduced by manually inlining code (not recommended).
Also, the section of the profiler report that displays the "other lines and overhead" only shows the top 5 most expensive lines in the function. A lot of the extra cost may be just the time used by the rest of the function and may be unrelated to first time costs or function calls. The detailed line listing at the bottom of the page displays the data for the whole function. It is even highlighted to show which lines are taking the most time (not just the top 5).