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!