I'm new to Android development. Now I am writing an application to control the robot by BLE. In the application, I added a virtual joystick and a couple of buttons, on my Meizu M2 mini everything works fine, but when I test applications on other devices it lags terribly and slows down. I rendered functions with a large number of calculations into separate streams, and in every way I tried to optimize the application, it became a little better, but still not usable. Are there any means to determine which part of the program loads the system most of all? If not, please share your experience, how do you determine which parts of the program load the system?
2 answers
The following tools are used to profile an application in Android Studio :
- Memory Monitor - shows the use of RAM memory profiled application. Allows you to force a call to the GC (garbage collector), get the contents of the heap ( HPROF Viewer ) and the allocation of occupied memory ( Allocation Tracer ).
- HPROF Viewer - Shows objects stored on the heap with detailed content.
- Allocation Tracker - shows which objects are in RAM, includes analysis tools, is used to search for leaks.
CPU Monitor - shows the load of processors by the profiled application, includes the Method Tracer tool for time control.
Method Tracer - shows the method call and the time spent on their execution.
- System Information - creates dumps in several system states.
- Network Monitor - shows the network load profile application.
- Android Device Monitor is a powerful profiling and debugging tool that includes several DDMS tools, Hierarchy Viewer , Systrace , TraceView , OpenGL Trace
- DDMS is a multifunctional profiler. Used before the appearance of the tools listed above in Android Studio and basically duplicates them. Convenient because everything is in one place.
- Hierarhy Viewer - used to optimize the layout and load the application screens. With Android Studio 2.2 it is included in the IDE itself and is called the Layout Inspector ( setting up the Hierarhy Viewer )
- Three tracers from ADM: Systrace , TraceView , OpenGL Trace to monitor application execution
Using these tools, you can fully evaluate how the application is executed and optimize it. I note that in working with each of them you need to write a separate article (there are also books on profiling, because the topic is very complicated) in order to use them effectively and understand their conclusion. Fortunately, these articles have already been written and Google knows where to look for them all.
- oneDude) Thank you! - Amir Shabanov
You need this . Allows you to monitor up to yes methods and the percentage of CPU load
- @BORSHEVIK pointed to the Android Device Monitor. Thank. - DimXenon
- If you want to be more precise, then this is developer.android.com/studio/profile/ddms.html?hl=en - BORSHEVIK