Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

TraceView for app performance testing

2025-02-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

I. introduction

TraceView is a performance analysis tool that can collect and analyze data. It can graphically let us know the program to be tracked and get the relevant method. This article only explains the function of TraceView when app starts. Of course, the stutter and delay phenomenon in the running process of app can also be analyzed.

TraceView mainly analyzes the running time of the method and the number of times it is called. In the app startup process, if the method takes too long to draw the first frame of the screen (16ms), there will be stutter, or even ANR (no response) and other problems.

There are two ways for TraceView to collect data. One is to call the Debug.startMethodTracing method where you want to track it by calling the debug class, and then call it again at the end (not highlighted here); another method is directly implemented through the start method profiling in DDMS (cannot be collected for cold startup)

II. Illustration with examples

Now let's talk about the start method profiling method.

As shown in the figure, select a process in DDMS (there is no process to choose from for cold startup, so you can only check for hot startup (the process is still there, just start mainactivity), and click start method profiling.

Then select the default method from the pop-up analysis method, and click ok.

Start method profiling turns black at this time, indicating that it is collecting, perform relevant app operations, then click start method profiling again to turn red at this time, and then pop up the information collected as shown in the figure.

Time panel

The time panel shows the execution of each thread, where [1] main is the ui main thread.

Move to a location to view the execution information of the method corresponding to that point, and click on the methods panel to select the corresponding method.

You can left-press and hold down the selected area to enlarge the local fine view, and different methods are marked with different colors.

Method panel:

The methods panel shows the execution of all methods. Click on a method to view the execution time area on the corresponding thread and display its parent and child methods.

Each method includes the following information columns, which can be sorted by clicking on a column to determine the function that causes the performance problem:

Incl Cpu Time, Excl Cpu Time, Incl Real Time, Excl Real Time, Incl Cpu Time%, Excl Cpu Time%, Incl Real Time%, Excl Real Time%, Calls+RecurCalls/Total, Cpu Time/Call, Real Time/Call

All Time are calculated in milliseconds. The specific meaning and function of each column are as follows:

A. Incl means that the time spent by all subfunctions is taken into account, while Excl means that the call time of the subfunctions is not included. The comparison can determine whether the time-consuming operation occurs in itself or in a subfunction.

B. Cpu Time means that it takes time for cpu execution. Real Time includes Cpu Time, waiting time, switching time, and so on, so it is generally greater than Cpu Time. The comparison can determine whether the time-consuming operation is within the cpu execution segment.

c. The% corresponding to the above four indicators represents the percentage of the function in the total time. It is convenient to view the percentage of time of a function.

D. Calls+RecurCalls/Total represents the number of external calls + recursive times / total times. You can check whether the number of calls meets your expectations.

E. Cpu Time/Call, Real Time/Call represents the ratio of total Cpu Time and Real Time to the total number of calls. To see the time spent on each call, you can generally determine the performance of each function by simply using this item.

A picture is more intuitive.

Test method:

Find out the method with a large number of execution time and calls in the diagram and optimize it.

Please refer to this http://www.cnblogs.com/sunzn/p/3192231.html and https://www.youtube.com/watch?v=gk2G_FAESds&list=PLaYqF7AnyNPcllCrHZFNQrjGTPO8gCb28&index=66

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report