cputime and tic...toc: high time difference
17 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
cputime and tic...toc are giving very different execution times. I am doing:
function[time, output2] = foo(input1, input2)
start = cputime;
tic;
...some computation
toc
tic;
...some computation
toc
...eccetera
tic;
...some computation
toc
time = cputime - start;
end
and I get this:
[t, ~] = foo(input1, input2)
Elapsed time is 0.564095 seconds.
Elapsed time is 119.898174 seconds.
Elapsed time is 76.127796 seconds.
Elapsed time is 3.465138 seconds.
Elapsed time is 0.240975 seconds.
t =
376.4200
that doesn't sum up to the total time at all. Why is it that? There are no code lines exluded between tic...tocs
0 comentarios
Respuestas (1)
Steven Lord
el 7 de Feb. de 2019
See the "The cputime Function vs. tic/toc and timeit" section on this documentation page. One potential big difference is how many threads are working and for how much of the time they're working versus sitting idle waiting for something to do.
0 comentarios
Ver también
Categorías
Más información sobre Performance and Memory en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!