adding breakpoint to program slows it down a factor of 250x

조회 수: 16(최근 30일)
I observed this in a larger program, then created a simple test case to ask this question.
The following program takes 0.038 seconds to execute without any breakpoints.
tic;
for ii=1:16000000
xyz=1;
end
toc;
z=1;
But if I set a breakpoint at the line of code for z=1, it takes 9.3 seconds to execute.
Is this normal? Is my system corrupted somehow? Any feedback much appreciated.
Rebooting the computer doesn't make a difference. I have 32G of RAM available so that shouldn't be the problem. Not sure what other knobs are available to try to get better performance.

채택된 답변

Matt Fig
Matt Fig 2012년 12월 18일
It makes sense to me that MATLAB would be slower when you are debugging. So what is the big deal? You won't be in debug mode once the program is ready for use, will you?
  댓글 수: 9
gkk gkk
gkk gkk 2012년 12월 18일
Thanks so much Matt, that really helps.

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

추가 답변(1개)

Teja Muppirala
Teja Muppirala 2012년 12월 18일
Might I suggest using the KEYBOARD command? It's a bit simpler than setting up dbstops and trys and catches, and works just as fast.
tic;
for ii=1:16000000
xyz=1;
end
toc;
keyboard;
z=1;
  댓글 수: 2
gkk gkk
gkk gkk 2012년 12월 18일
Great! And there's no hit from performance using keyboard.

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

Community Treasure Hunt

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

Start Hunting!

Translated by