Code runs much faster in debugger
2 次查看(过去 30 天)
显示 更早的评论
Hello,
I have a quite large project in Matlab, which involves object oriented programming. While running some tests I have noticed that parts of the code actually run significantly faster in debug mode. That is, I set a breakpoint at a line of code that whill never be executed, and boom the code executes 3 times faster.
The parts where the difference seems to occur are all in constructing a large, sparse matrix. E.g., a typical assignment for setting the values of a column:
obj.Hcoupling(coupledStates, k) = 0.5;
Hcoupling is a sparse matrix, coupledStates is a list of indices, k is a scalar. Can anybody tell me what is going on? How can this be possible? And, most importantly, how can I get this 3x speed increase in my normal program execution :-)
Thanks in advance,
Rick
PS. This "question form" with its fancy preview is HELL
0 个评论
回答(2 个)
Andreas Goser
2011-2-18
Not that I know WHY that is faster in debug mode, but one aspect is that The JIT accelerator is disabled when debugging. Naturally, the JIT accelerator shall accelerate, but it may be an issue in the JIT implementation. Please try:
feature('accel','off')
feature('jit','off')
And run your code. If it also runs faster, then there maybe is a JIT issue.
0 个评论
Rick
2011-2-18
1 个评论
Andreas Goser
2011-2-18
So then the test appear to be not helpful. 'accel' 'on' should normally faster and that is what you observe. I was however suggesting that you compare the (both) 'off' settings with running in debug mode. But all in all it looks my attempt goes in the wrong way
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!