TraceView instructions for using the Android performance analysis tool

Source: Internet
Author: User

TraceView is an Android platform equipped with a good performance analysis tool. It can be graphically used to let us know the performance of the program we want to track, and can be specific to method.


TraceView Introduction

TraceView is an Android platform-specific data acquisition and analysis tool that is used primarily to analyze hotspots for applications in Android. TraceView itself is just a data analysis tool, and data acquisition requires the use of the Debug class in the Android SDK or the use of the DDMS tool. The use of the two is as follows:

    • The developer calls the Startmethodtracing function of the Debug class in the Android SDK before the start of some critical code snippet and calls the Stopmethodtracing function before the end of the critical snippet. During the run of these functions, the function of all threads of the application (note, Java threads only) will be collected during run time, and the collected data will be saved to a file under/mnt/sdcard/. Developers then need to use the TraceView tool in the SDK to analyze the data.
    • with the DDMS tool in the Android SDK. DDMS can capture function call information for a running process in the system. For developers, this approach works for situations where the source code is not applied to the target.

ddms in TraceView use as follows, the debugger can click on the    button by selecting the app in the Devices Start method Profiling (Open methods Analysis) and click    stop Method Profiling ( Stop method Analysis )

After opening the method analysis to the application of the target page test operation, after the completion of the test Stop method analysis, the interface will jump to the DDMS trace analysis interface, as shown in:

TraceView interface is more complex, Its UI is divided into top and bottom two panels, the Timeline panel (timeline panels) and the profile panel. The upper half of the  timeline panel (timeline panel) , timeline panel  Can be subdivided into about two  pane :

    • The left Pane shows the thread information collected in the test data. This test data captures the information of main thread, sensor thread and other system worker threads.
    • The right Pane is shown as the timeline, which is the function call information involved in each thread test time period. This information includes the function name, function execution time, and so on. From the figure, thread-1412   thread corresponding line is very rich in content, Other threads have much less work to do during this time period.
    • In addition, developers can move the timeline vertical axis Pane the timeline. The top of the vertical axis displays the function information that a thread is executing in the current point in time.

 PROFILE  Panel (analysis panel) , profile panel is the core interface of TraceView, and its connotation is very rich. It mainly shows the case of each function call in a thread (select a thread in the Timeline Panel first), including information such as CPU usage time, number of calls, and so on. This information is the key to finding a hotspot. So, for developers, be sure to understand the meaning of the columns in the profile Panel. The following table lists the more important column names and their descriptions in the  profile panel.

Actual Combat analysis:

First find your own writing class, here in my own writing addgoodsmatchactivity For example, you can know that its OnCreate method of public occupation 314.069ms,oncreate method occupies the time is also very clear. Focus on analyzing its Setcontentview method, as it occupies 266.874ms of the entire OnCreate method 82.5%, click Setcontentview method

Then click Setcontentview


Then click Inflate

Thus we can see the time of our own method invocation, the number of calls, and thus the analysis of the problem

TraceView instructions for using the Android performance analysis tool

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.