5

Is there a good way (proper way, or effective way) to debug slow running code?

I have a thread which runs multiple loops and then recurses and my code is running very slow.

Is there a good way to debug different loops or sections of code to find out which is running slowest?

If the debugger already does this, can someone please explain how,

Many thanks

1
  • Once you determine where the bottlenecks are, this may come in handy: developer.android.com/guide/practices/design/performance.html Commented Jul 10, 2010 at 15:02

2 Answers 2

2

What you need is not a debugger, but a profiler. Check this tool from Android's SDK: traceview

Sign up to request clarification or add additional context in comments.

1 Comment

I think you can use the functionality of that tool within the Eclipse plugin too, although I haven't yet tried to do so.
1

One of the most primitive ways to determine slow points is to litter the code with print statements. Bottlenecks then show up as delays between prints. This can be improved by printing the system time as you move from one loop to another, making it trivial to determine the slowest loops.

A solution that is potentially easier and more thorough is to use a performance profiler. Most mainstream languages will have standalone profilers or debuggers with performance profiling built-in. A good profiler will determine the percentage of execution time spent on each area of your code and offer useful information for optimizing performance bottlenecks.

If you need more specific information it would be helpful to post the language you are using as well as relevant sections of the code.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.