Android - slow debugging code

Is there a good way (right way or efficient way) to debug slow code?

I have a thread that starts several loops and then recurses, and my code runs very slowly.

Is there a good way to debug various loops or sections of code to find out what works slower?

If the debugger is already doing this, can someone explain how,

Many thanks

+4
source share
2 answers

You do not need a debugger, but a profiler. Check out this tool with the Android SDK: traceview

+2
source

One of the most primitive ways to determine slow points is to hush up the code with print statements. Bottlenecks then appear as delays between prints. This can be improved by printing the system time when moving from one cycle to another, which makes it trivial to determine the slowest cycles.

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

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

+1
source

Source: https://habr.com/ru/post/1315221/


All Articles