Profiler: time spend at while END statement
9 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I run a profiler on my code, and it is reported a significant amount of time is at the "end" statement of a while loop (here i, n, pivot are scalar, A, idx are vector and cmp is an anymous function that returns a logical)

How to interpret those times ?
1 comentario
Respuestas (1)
Jan
el 29 de Mzo. de 2022
Editada: Jan
el 29 de Mzo. de 2022
I interprete the displayed "times" as a a general problem of the profiler: Matlab's JIT can reorder commands and find abbreviations for the execution of code. This is essential for the speed of loops.
Unfortunately it is impossible to measure the timings line by line, if the JIT has re-organized the code. My opinion is, that the profiler makes the "end" responsible for some computations, which are moved out of the loop's body. This is equivalent to nonsense.
Measuring the performance of Matlab code is a fragile: The profiler reduces the JIT partially or completely. This is not documented exhaustively, but even if it is, it would be subject to changes between the releases. timeit includes some overhead for the anonymous function, tic/toc is not precise, tic/for k=1:1e6/toc includes overhead of the loop and maybe the JIT removes some work, cputime contains magic artifacts. At the end, the timings depend on the temperature of the room, if the CPU throttles.
In short words: The output of the profiler is not reliable.
0 comentarios
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!