Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use "Overhead" tab in Android Studio 3.1 debugger?

While debugging my app I've noticed a tab in Android Studio 3.1 under the Debugger tab - Overhead. It has some of my method names listed with a Time(ms) metric:

Overhead tab in Android Studio

I can't find any info about this tab, what is it for and how to use/read it, which is a shame because it seems useful.

Can anyone give some explanation or point to the documentation?

like image 874
Tadija Bagarić Avatar asked Apr 04 '18 13:04

Tadija Bagarić


People also ask

How do I run Android in debug mode?

Press Ctrl + Alt + F5 (or Shift + F9 ) to launch the app in debug mode. Choose Run -> Attach to process and select the signature of an app to enable the debug mode, which is already installed via adb.

What debugging tools are available for Android?

Logcat and Debug are two tools that come built-in to Android Studio, which you can use to identify and fix bugs in your Android code.

How do I debug a process in Android Studio?

To do this, click Attach Debugger to Android Process. In the Choose Process dialog, highlight the process you want to attach the debugger to and click OK. Now, you’ll start hitting your breakpoints as you normally would in a debug session.

Do you spend more time in the debugger than in editor?

As developers, we all know that there are days we spend more time in the debugger than in the code editor. With this in mind, I recently took the opportunity to see what tricks and tips members of our Android Studio team had for speeding up debugging.

How do I backtrack in Android debugger?

If you’re running Android 10 or higher you can now backtrack by clicking Drop Frame in the debugger toolbar. This feature pulls you out of the current method and puts you back to the point before it started, giving you a second opportunity to step into the method.

Why is my code stuttering in debug mode?

When you have a conditional breakpoint where you evaluate an expression, even if you don’t stop at that breakpoint, the debugger still has to do the evaluation. If you are running some code in a really tight loop, such as animation processing in a game, this can cause the application to stutter.


1 Answers

TL;DR: It shows you the "performance loss" of using the debugger.

Since Android Studio is based on the IntelliJ IDEA, you may find some information about this feature here:

https://blog.jetbrains.com/idea/2017/09/whats-new-in-intellij-idea-2017-3-eap/

As its name suggests, this tab shows you the overhead added either when stepping over the code or when Data Renderers evaluates values to display them in Variables, Watches, or other places.

And even more infos (including a small gif showing the feature) here:

https://blog.jetbrains.com/idea/2017/12/intellij-idea-2017-3-debugger-improvements/

Where they state:

Debugging an application comes with an inevitable cost. While we may know this, it’s not always obvious what this might be. IntelliJ IDEA 2017.3 comes with a way to visualise this cost. There’s now a new tab, Overhead, which gives a view of the cost of debugging. [...] As you can see, this window shows how much time was spent stepping over code, or rendering values with custom Type Renderers in watches and variables. Seeing this overhead may help you to understand the difference in behaviour between running and debugging your application, and will help you to reduce unnecessary performance costs when debugging.

Here is the gif animation showing it's usage:

Gif animation showing how to use it

like image 149
Tobias Reich Avatar answered Oct 02 '22 19:10

Tobias Reich