Duration 30:44
16+
Play
Video

Improve app performance with Android Studio Profilers

Esteban de la Canal
Tech Lead at Google
  • Video
  • Table of contents
  • Video
2018 Google I/O
May 10, 2018, Mountain View, USA
2018 Google I/O
Video
Improve app performance with Android Studio Profilers
Available
In cart
Free
Free
Free
Free
Free
Free
Add to favorites
27.66 K
I like 0
I dislike 0
Available
In cart
Free
Free
Free
Free
Free
Free
  • Description
  • Transcript
  • Discussion

About speaker

Esteban de la Canal
Tech Lead at Google

Esteban is the tech lead for the Android Studio Profiling Tools team and also contributes to the overall Android Studio effort. Prior to Google, he worked in the games industry developing console video games. Esteban holds two Computer Science degrees from the National University of La Plata, Argentina.

View the profile

About the talk

This talk will demonstrate how to diagnose and troubleshoot performance problems with your app using Android Studio Profilers. It will cover examples of how to use the CPU, memory, network profilers, and highlight what's new.

Share

My name is sister and I'm the leader of the profiling Sinatra studio. And today I'm going to show you all the new features. We have another to disappoint you on some of the features that we launched in Andrew 23.1 in the profilers. Right, so I'm going to be doing a demo for most of the session but just in case you haven't seen their profiles before just to get an idea how many of you have used the profilers in the hole. That's great. But most of you have seen them but we

have a new profile or that I'm going to be introducing today. That is the energy profiler. As you know, we have the money towards that show you like lemon tree from the app and we have a CPU Network a memory and the new energy provider and you can diving into any of those and infratemporal inspect your nipple request. See what you made a request from code. See what you actually downloaded what it was sent. You can also diving into the memory profiler see the breakdown of the memories see how many objects you have located where you located them. You can also

dive into the CPU profiler. I'm going to be showing some new cool features and we added there in 3.2 specifically C's price again. I'm going to ask the question how many of you have you see straight before we started with the first types of integrating sisters in to the Android Studio C view profile. I'm going to be there mowing dad in a few moments and last but not least is the new energy profiler that will guide you in finding senior app that could lead to energy profiling in

energy issues more about that at the end of this section. And with that that's it. That's all these nights and I have some going to move to the Denver now. I have to make a disclaimer so All the features and I'm going to be there mowing today. I'm under Studio 3.2 Canary and there is a reason why they're not in the stable release yet. So we might be in for a bumpy ride, but I want to show you what we have and you know, if we just keep it between us and people watching on YouTube and that's it. All right. So

next week look app that has the clock. It has a stopwatch that you can click something. That's the timer. I don't want a profile it with you guys. So let's first start with nether profiler. So this app has a lot of features on the clock app should not have for example in needs internet access in need to access location. So one of the features enhances you can change the background, so if the internet connection isn't good enough for this thing is going to start downloading some images right now. You

can that be named to the network for filer you surely have seen this before and you can see all the network request and have it done. You can click on them and see the actual payload something new that was added in 3.1 is the ability for us to see what we sent received, but we can say the payload or the custom headers that we use. In this case. I have one custom Heather Dunn says threesome another new feature in 3.14 the net worth of Tyler and that is the street view. So as you see here, we show you

the request in the time. but if you choose since you when you can see is on which thread and this is and let me close this so we have more space to go so you can see if you request on which thread it was made and if we have more like this. I'm using a standard a synchronous task which uses a default executor that will run them sequentially and you can see them and if they were using the same thread you can see them to you. But if you rap you have a more complex threading with memory Quest you can use view to see what's going on. So

those are two new features on the net worth of Tyler that we've added in 3.1 and now I'm going to move to the memory profiler. Let me go to the PlayStation. Ethiopian review before we split up how much memory are using into different components. But we also show you the number of object. You have located an Android Oreo phone or newer we have this is this is super cool. We have a future call Lima location tracking remember back in the back in the day when you had to do a location tracking you have to click

a button to record locations and then you would see them. Well, if you wanted to know what happened here, we can see that the object has been garbage collectors garbage collected. Did you want to see what's happening? Just select a range and we we have the information of every single object that was allocated there at which time it was allocated and wearing your coat. It was allocated and you can slide this window and you can see this thing changing. So if I slide it over a garbage collection. You will see which objects were they located. Let me close this window.

There we go. We can see that there was a lot of stinky elevated so we can start actually having a new car this app and see how bad it is written. For example, if I see what was located I can click on any one of those and see where I am located them and I are located them inside and don't draw this is not a good idea if you have it on you, but I'll look at Lost Springs there bad things will happen and we see more about that. So the Seaview profiler, but this is already starting signals about when my app is doing

wrong. another music that we add an entry point to is the ability to see j&i global references. This is very important because a lot of memory leaks occur because one Jane I give a reference is created. I'll let you know when we created it and we don't know where it is. So when you select the range when I have you in my ass every time I download an image, I want to feel threatened sleeplessness to darken it. So the phone can be seen and I have a bruise there and I hope I didn't I do right right

so we have Especially keep which religion he said when you selected you can see all the global references that existed in this range of time. In this case I have this into right and I don't like 281, but it should have been gone. So let me go live here and select range. and here it is this is My Global, this is every image that I downloaded. Are you still holding a genogram a reference to it? And I can actually navigate to the seedless plants line of God. Would I created that girl reference? I never let go. I hope this is useful to track down problems

with local references in Jane Eyre. One more thing. You probably have been seeing all the time on the left that we have a new panel for the sessions panel. Well now we all know you to see previous station that you have V profile. So you can navigate back and compare previous run still here working on organizing your Ave. What did I change? You can go back and see if this will hopefully we can go back and see what the weather will be nice and what happened, but that open the door for us to do things like this now we can I'm going to eat for

the keep them. And this keep them is being reported directly to the new profilers any threats or request a station for it and you can analyze the keep them as you're used to in the revivalists. You can also import races for you and everything we can so that's pretty handy on this is a new and 3.2 and this is what I wanted to show for memory and then we're going to go to CPU and spend most of the time there. This Is The Life session And I'm going to show you one feature that you have. All right, so 1 things that

we wanted to add was the ability to profile since the beginning. So if you've used it for 5 if you know this and if you want to go find your app startup you have to put in to go to see if you ever find her and record so you can see what's happening. What you can do is if you go to the Profiling job. We have a notion that it's not recording a message trace on Startup. So I have the sticks. You can choose the configuration that you want. In this case. I'm going to use the sample Java configuration, and I'm going to rerun the app.

No. You can see that the I restarted the profilers took me directly to the CPU profiler and there is already a capture in progress from the very beginning of the app. So I'm going to stop it now. And we're going to investigate what happened there. Take a few seconds to get the date. Unless you can see the resolution on the screen, but let's have a look and see that. I'm going to select the very beginning of the app. Looks like you can see that they capture started even before our Telemetry could

start getting data from the app, right? I wasn't even started here, but they have started before and we can see the Dayton and if we keep zooming in there, you can see the First on create of my main activity and even before that we can see when will Texas or lower than the very very beginning of your episode with this mechanism. You can profile from the very beginning optimize the start that timer. Let us have a look at this capture and see if those drinks with so before are actually causing some problems. One of my favorite

color is the flame chart chart aggregate all the college stats. Then have the same beginning so you can see is facing you this talk down tree, but it never should wait and you can see that. One of the biggest things is my own draw the way I roll this app is on every frame. I'm rendering everything again. That's not a good way of doing it, but it's really good example for the profiler so you can see that I'm rendering and there is a lot of things have the top that have to do with string formatting and this could be the source of our

spring crawling up you so before so it's another symptom that your office is not doing what one thing that I always say about our profilers is that we cannot really tell you what's wrong in your aunt. We can only tell you what your app is doing. I'm going to talk to you to say oh I didn't expect this to happen because as you can see my app looks fine, but under the hood is not so let's say you have a burger on a label that you put the wrong. I just need different position. You're right. You're up. You see there is always wrong. I need to fix it. But if you have something like a performance

issue wrong, you won't see it. You won't see it until we talk about battery later and you will see it in the field. Right? So we want our profilers to be another window to your house so that you can run your lap while seeing the profilers and then you see the problems there because something that you did not expect start showing up like me doing a lot of string formatting inside and roll call. So let's go to the code. When I have my I have and I have a function called real-time where I draw the time on

my app. I have to function call draw time string that uses string formatting to draw the time and it's probably not a good idea. So without using strings are we going to try. Let me show you one thing that we have here. So how many of you are familiar with this line of code phrase that begins section. Did you please hun school? So what this together with the intersection they were traded Secrets event that you can use scissors to see. So before I make my optimization, I'm going to Show you what happens if I take a picture using

the system Trace method? Oh, so this is running Secrets under the hood. I didn't have to go to the python script anymore and then get it and then getting back on your on the HTML view. We will instead show it to you right here in our out in Android Studio. Remember when I mentioned going to copyright? This is it? Let me restart emulator. I would do it again. There we go. Please please try this at home file bags. We will fix them and when we get to stable, these issues will be all sorted out.

There we go. Going to go to Seaview profiler and use the system price. second time's the charm Let me select. I'm zooming to selection to one thing that you know, what is here that first of all, we have a new section deal there gold liquor intersection where we show you all the CPUs. And if you pay close attention, we rear-ender all the strain information getting all the data from Sister. He's so before Display information we get sampling they profile system. So it's not very accurate. But as soon as you take a seat trade capture, you can see exactly

where what your thread is doing at every moment. I'm more than that if I select one of those we highlight above on which CPU your thread is being scheduled so you can look at 3 convention or all the things aren't kicking you out of the Sea View. What is the fundamental difference in the way? We show Secrets here with the way you see it in the HTML view here. We focus on your app. So everything here that is highlighted green. Even the dark green is just your app. You can still go and see the other events and see what is taking me to be or why

you're being kicked out but we focus on your app will show you the stress of your answer. You have to navigate that gigantic HTML page and we use all the other things that you know about all the other captures. We use them for c space for example blank chart or top down View. So let me zoom in. the moment in time that we can see her frames So I have here let me zoom in more. I'm just not really my main threat there go. So we can see the choreographer do frame and further down. We can see the laundro on my custom component

and we can see the drill time remembering the code. Let me go back to the code and show you in thrall time. We have to draw time around the section around my hamstring and you can see that I'm bringing you three times one for every section of my out and we can put you see how long each one of those is taking right? So I'm taking 38 milliseconds to render frame if you want your afternoon at 60 frames per second. You have to run their under-17 each Frank milliseconds. Now, I'm way over there inside one of Michael's to draw time is taking 11 minutes.

So my house is not doing well. It looks okay, but imagine you ship this and this is one of the things that I was mentioning about you look at your house. Do carrots really provide a glass to see if it's doing okay. I'm going to he's going to take enough drawer time. Now instead of using is Springs. I'm using my my custom formatting if there's anything for my time using my cousin for mudding with running again with these changes and we'll run it to Citrus and see how that affected my app.

Go there, it is going to go to Seaview profiler these phrases chosen for me and I'm starting to capture just a few seconds should do it cuz they're a lot of friends and have it in there. Cool, we have a year. right men's red selected zoom into specific Prime. We have the choreographer to frame in the framework and then it goes down to the clock on row and you cannot see any more throw time functions cuz they're down there each one of them now taking 71

microseconds and the old row is 13 milliseconds now. So we did that now. In other places, but at least we have a nice one part of it to see space and let me mention again sessions. So remember I said you we can go back and compare or I have my favorite stations here in the left and we can see the previous history stranded with it. So here it is. I can select it again. Look at the Main Street and see how bad my drawer time was and then go back to the currently running session and you can keep all of this and of course if you right you can explore the trace and send

you on the Bayou or want to keep them. You can explore these things right here from the station funnel. holding me like this I'm not sour. implements nuts our integration with her sisters, so There's another way of capturing Seaview datum. That is 70 PSI in the debugger. Let me go to the line of code. So, how am I still watch and I'm going to change it to every time that I start my stopwatch. I'm going to run start my heart racing and every time that I started going to stop method racing. I need to import and I'm going to rerun the app.

before this When's wants to run this if you have to go in the fridge this file and open it in either any of your favorite profile as I can open it right by. What's right now? If I'm to see if you have a fighter and I use my stopwatch. This is what happens. So now I'm taking you capture on this to differ find is detected that captures being taken place. I'm going to showing you theirs and when I started I don't need to go and fetch the fire from anywhere, we pull it from the device and we show it right there. So you find start on the stove and I start on stove all

these captures not actually overriding each other because they use the same device for pulling it and showing showing them on studio. So that's super handy when you want to profile exactly Moment In Time. Navigate to all of them and you can see them here in two sessions final two. That's pretty cool. One more thing. We added in 3.1. Where am I? another way of comforting CPU usage using the C plus plus something to a Goldstein prefer that if you go to the invitation in Android developers that

you would find documentation about simplify. We have a version of zebra birth inside under studio and allows you to sample C Business code and season 10 equal sides of your sympathy the first program. I'm going to do that cuz I don't have it at a CVS test. cool, so that's see if you were fighting and let me move to the energy for Fido now, so Energy spooky energy speaking because there are two main sources that use energy on your phone using the phone. So you're using a game right this all the time is in Spain, but

the battery drain problems usually happen when we use CPU or network when the user is not aware of this of this. So let me go live. I'm using a fair amount of CPU on on this app and If I going to the energy profiler. We classify this is like use of energy we will show you hear things that this is. Represent how much energy you would be using on Modern phone? I'm not refining how much energy is using. Obviously. Nobody says to press to see. Okay. I'm doing well or nothing Well, I'm going to show you some things that show up here. But obviously the two big factors are CPU and network. I

just thought you know, everything is okay. Just don't you see if you are not work, but why am I using that in the field and the problem is not actually when we use it is the problem is that we don't know we're using it. So let's say I have a white cloth that runs runs amok and we don't know where it is. Using CPU, or I have an alarm that I didn't set up correctly and that is called it was waking me up and I'm making it for request so it's not about Natural Energy is about all these things that you could be doing it correctly that could cause battery drain in the long-term. And this is

part of what I was saying before that used to be running seems to be fine. If I were to put this up to the Play Store and you started on your phone. This is going to be the most expensive battery speaking Club you ever have on your phone. I'm going to drain your battery, right? And I don't know what this so we're looking at their profile as we can see that constantly. This is draining CPU. And we can start investigating why like I said, I have a white cloak that I don't release or I have an alarm. So we wanted to give you a window so you can see the things happening the

same way. If you have a label in the wrong place, you can see it. We want to show you if you have an alarm that you didn't cancel or do you have an alarm in the wrong place or we're going to show you that? So let me show you. peace of mind when I have a timer So here I can run a 10 second timer. You can see at the bottom of the energy for filer that dries yellow line that showed up on it. That's an alarm or if we show you both there and you can see that when the timer stop the alarm went away

and you can start the timer again again, I have the alarm on this actually when I was developing this was for me to see okay. I'm not doing it right when I stop the timer does my alarm go away. When I start again. Do I call you back? So this allows you to see this, please don't use my alarms for us for the timer on the club. I also have a wake log on. My stopwatch again don't use weight loss. Which and you can see that when I started I acquired a regular come when I stop it. I did it go and I can see that is working fine. If the red line keeps

going. I have the same people we have problems, but you can see it through this window that what is final now and we also track location. So if you are acquiring location, like I'm doing now we have these purple lines that shows you that your friend location. The emulator has a really handy feature that you can actually that it went to send a location event. So, you know where muzzle we show you that that is actually using energy. And again, you can see it in the purple bar on if I stop it.

There we go. They provide is gone. But more than that. I see how you use an hour to an hour or so, we can select range and we can show you that you had an alarm that you had a location request. If I move back we can select awake looking to do in a second more than that. I can show you where the location was acquired which kind of Provider I'm using a GPS provider so we can see that we can see things around times that I chose when the code I triggered it to have it dug a location that happens when I click the button. undem if I click on the alarm.

Not only I can see when I say the first time but when I reset it when I cancel it so you can see all the places in the code that that was trigger so I can see back problems when this is not happening correctly. Let me go back and show you the waking up is right there. I select you can see the way clock. And you can see every time that I started. I stopped the stopwatch. I was acquiring and releasing the white glove and you can see all the cuz that's when that happened. So this is the power of this is not to say, okay, you're using a little battery. Well, yeah,

I'm a game. I want to use battery. So it's fine. The power of this is so that you can see that you're happy doing what you think is doing which is not you should go in and fix so that's an energy provider. Let me show you one more thing. I want to show you. On the left. We have Decisions by now and let's go back in time. I can stop the current session August. And then you can click on other stations. And we can start comparing all the capitals that we did. Back from when I started to talk. Here I just was the first time we run it and we keep all this information until you

restart studio. So you can confirm runs and let me show you the last thing. I want to close with that nitrous a few minutes early. All right, like I said before I'm rendering every frame I'm doing something that I should not be doing. That is anybody they think of you all the time and that he's using a lot of CPU. so let's go back to my activity where I have the code, but that's is so I have my mother that I update every frame and then I invited 8 all the time. My mother has the ability to know when it has changed. So I'm only going to anybody that the Cannabis

whenever something has changed. I'm going to see the effect that. Has when energy CPU and support. Punjabi gun There we go. You can see now that the energy profile are most of the time now is below like it was above medium before we can go play with previous sessions. But of course when they have to run their We can see that the energy usage starts going up. This is because I'm rear-ending my view every time. And you can see the effect here. You can see it on the memory profiler to if I go back to the memory profiler. Remember that line that was going up

above I mean garbage collected that is gone. I do have some of these are being created and they will be playing later like here, but it's not as it was before. Let me talk to them and go back to the slides. Thank you.

Cackle comments for the website

Buy this talk

Access to the talk “Improve app performance with Android Studio Profilers”
Available
In cart
Free
Free
Free
Free
Free
Free

Access to all the recordings of the event

Get access to all videos “2018 Google I/O”
Available
In cart
Free
Free
Free
Free
Free
Free
Ticket

Interested in topic “Software development”?

You might be interested in videos from this event

September 28, 2018
Moscow
16
159
app store, apps, development, google play, mobile, soft

Similar talks

Marcelo Ferreiro
Director of Engineering at Jam City
+ 3 speakers
Benjamin Frenkel
Product Manager at Google
+ 3 speakers
Kyle Rushton
Director of product at Zynga
+ 3 speakers
Olivia Yu
Vice President at King
+ 3 speakers
Available
In cart
Free
Free
Free
Free
Free
Free
Filip Hracek
Developer Advocate, Flutter at Google
+ 1 speaker
Matt Sullivan
Software Engineer at Google
+ 1 speaker
Available
In cart
Free
Free
Free
Free
Free
Free
Alberto Medina
Developer Advocate at Google
+ 1 speaker
Thierry Muller
Engineering - Developer Relations Program Manager at Google
+ 1 speaker
Available
In cart
Free
Free
Free
Free
Free
Free

Buy this video

Video

Access to the talk “Improve app performance with Android Studio Profilers”
Available
In cart
Free
Free
Free
Free
Free
Free

Conference Cast

With ConferenceCast.tv, you get access to our library of the world's best conference talks.

Conference Cast
558 conferences
22059 speakers
8190 hours of content