Profile Total time vs timeit

조회 수: 12 (최근 30일)
Augusto Perboni
Augusto Perboni 2022년 10월 13일
편집: Jan 2022년 10월 25일
I am studying the efficience of my code and to do that I was measuring the time spent to run the code. But when I use the function timeit to measure it the anwser is 0.15s and when I use the profile the total time is 0.5s. I dont know why the difference in time by measuring it those functions. Anoyone could help me to understand that?
  댓글 수: 3
Augusto Perboni
Augusto Perboni 2022년 10월 25일
Thank you for yor anwser Bjorn, yes it was great to find the bottle-neck of the code. I asked about that just to try to understand a bit better what was going on. I think you are right and it have some to deal with the compilation optmization.
I wish you the best, thank you for your time
Bruno Luong
Bruno Luong 2022년 10월 25일
Profiler is like a measurement device and your code is like a particle in quantum mechanic: you measure it then you perturb it.

댓글을 달려면 로그인하십시오.

답변 (1개)

Jan
Jan 2022년 10월 25일
편집: Jan 2022년 10월 25일
The profiler disables (at least parts of) the JIT, the just in time optimization. This happens, because the JIT can reorder commands, if it improves the speed. But then the profiler cannot correlate the processed command with the code lines anymore. This means, that the detailed profiling impedes the processing speed and this is, what the profiler should observe. What a pity.
If the bottleneck is a simple loop with elementary commands, the JIT acceleration can be strong. Then a bottleneck found by the profiler must not be a bottleneck in the real processing.
timeit and tic/toc are less smart und more accurate to compare runtimes between different versions of a code.

카테고리

Help CenterFile Exchange에서 Performance and Memory에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by