Code runs much faster in debugger
7 views (last 30 days)
Show older comments
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 Comments
Answers (2)
Andreas Goser
on 18 Feb 2011
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 Comments
Rick
on 18 Feb 2011
1 Comment
Andreas Goser
on 18 Feb 2011
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
See Also
Categories
Find more on Logical in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!