Why does profiler include idle time?
Show older comments
The Matlab profiler is behaving in ways I do not expect. For example, I have a very simple function that looks like this:
function ptest(N)
a=fftn(randn(N,N,N));
Now If I paste this text into the matlab command window:
profile on
tic
ptest(300);
toc
profile report
I get a profile report that tells me that the function ptest ran for 0.94 seconds (fairly consistent with toc) with the fft line taking nearly all the time and being called exactly once... so far so good!
However, if I then type this code into the profiler:
profile on
tic
ptest(300);
toc
pause(8)
toc
profile report
I have two toc lines... one gives 1.09 seconds and the other gives 9.10 seconds (all this makes sense). However, the profiler tells me that the function call took 8.923 seconds! In fact, if I wait another 10 seconds and type profile report again, it tells me the function call took 19 seconds!
4 Comments
per isakson
on 13 May 2015
With R2013b I cannot reproduce any of the behavior that you describe

Jed
on 13 May 2015
@per isakson: Thanks so much for checking this! The proposed answer by Philip below could explain this behavior if you are using windows. If he is correct, I would expect windows to still have the following problem, which I would try to verify if I had Matlab for windows:
type in the command window:
profile on
ptest(300)
Now wait 10 seconds and then type
profile report
If Philip is right, I would expect that even the windows version of matlab would give funny results because everything would be normalized to the wall clock time between the initial command "profile on" and the eventual command "profile report"
Accepted Answer
More Answers (0)
Categories
Find more on Entering Commands in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!