TraceView of Android Debugging Tools

Source: Internet
Author: User

TraceView is a good performance analysis tool equipped with Android platform. It can be graphically used to let us know the performance of the program we want to track, and can be specific to method. The version limit for TraceView is for Android 1.5 and below: not supported. For Android 1.5 + 2.1 under (with 2.1) version: limited support. Trace files can only be generated to an SD card, and you must include code in the program. For Android 2.2 (with 2.2) version: fully supported. Can not use the SD card, do not add code in the program, directly with their own DDMS can process TraceView. One, Android 1.5 above 2.1 under (including 2.1) version of the use of TraceViewFirst, the code must be added to the program to generate the trace file that we can convert to a graph with this trace file. 1.1. Start trackingUse the following static method method of debug to start: static void Startmethodtracing (String tracename) Start method tracing, specifying the trace log file n Ame. To start the tracing of methods using the name of the specified trace file and the default maximum capacity (8M) static void Startmethodtracing () Start method tracing with default log name and Buffer size. Use the default trace file name (dmtrace.trace) and the default maximum capacity (8M) to start tracing the method of static void Startmethodtracing (String tracename, int buffersize, int flags) Start method tracing, specifying the trace log file name and the buffer size. Use the name and maximum capacity of the specified trace file to open the Tracking of the initial method. And you can specify flags. NOTE: Int flags doesn't seem to make sense. Generally used 0.static void startmethodtracing (String tracename, int buffersize) Start method tracing, specifying the trace log file Name and the buffer size. Start tracing the method with the name and maximum capacity of the specified trace file. Note 1: The above method of the file will be created under the SD card, that is, "/sdcard/", the default file name is "/sdcard/dmtrace.trace" if there is no SD card, The above method throws the exception and causes the program to crash. NOTE 2: If the file name does not specify a type, the system adds the type. Trace 1.2. Stop TrackingUse the static method method of debug to stop: public static void Stopmethodtracing ().    For example, add debug.startmethodtracing () to the activity's OnCreate () and add debug.stopmethodtracing () to OnDestroy () as follows: @Override        public void OnCreate (Bundle savedinstancestate) {debug.startmethodtracing ();     Super.oncreate (savedinstancestate); ..............................     } protected void OnDestroy () {Super.ondestroy ();.... ..... Debug.stopmethodtracing (); For the simulator we also have to create an AVD with SD card so that the trace file can be saved to/sdcard/... Of They can be created separately in the command, or they can be created together with the sdcard when creating the AVD. After creation through the Ddms file explore we can see a trace file under the/sdcard/directory, and the default is Dmtrace.trace if the name is not set in the debug statement. 1.3. Copy trace files from SD card to computerNow we copy this file to the directory specified on our computer: adb pull/sdcard/dmtrace.trace D: 1.4. Start TraceView Visual InterfaceYou can now execute TraceView from the command line. After entering the tools directory of the SDK, execute TraceView, as follows: TraceView D:\dmtrace.trace. Then you can see the graphical interface. 1.5. Analysis of TraceView resultsThe upper part of the Timeline panel window is the timeline plane (Timeline panel) The image below shows a close up of the Timeline panel. Each thread's execution is shown in it own row, with time increasing to the right. Each method is shown in another color (colors be reused in a round-robin fashion starting with the methods that has the Most inclusive time). The thin lines underneath the first row show the extent (entry to exit) in the calls to the selected method. The ruler above the interface represents the The time period of the methodtracing (from Debug.startmethodtracing () to Debug.stopmethodtracing ()). The function execution time graph for each thread is on the right side of the line Cheng row. Note 1: The line width is used to perform the operation of the function itself. TimeNOTE 2: the sub-function timeline called by the function is interspersed between the time lines used by the function itself. Note 3: The height of the timeline doesn't know what it means. Note 4: The function itself is nested. Note 5: A thick segment below each line marks the time period consumed by the selected function call in the profile panel. Each segment corresponds to the run of the function once. In the figure below we can see that there are 11 calls to loadlistener.nativefinished (), one of which is particularly time-consuming. Here are 11 times and Figure 2 is not consistent, it should be Google's negligence. Figure 1The Traceview Timeline Panel Profile PanelThe lower half of the window is a summary of each function call Panel  figure 2 shows the Profile pane, a summary of all the time spent in a method.& nbsp The table shows both the inclusive and exclusive times (as well as the percentage of the total time).  exclusive Time Was the time spent in the method. inclusive time was the time spent in the method plus the time spent in any called fun Ctions. we refer to calling methods as "parents" and called methods as "children." When a method was selected (by clicking in it),  it expands to show the parents and children. Parents is shown with a purple background and children with a yellow background. the last column in the table shows The number of calls to this method plus the number of recursive calls. the last column shows the number of calls out Of the total number of calls made to that method. in this view, we can see that there were calls to LOADLISTENER.N Ativefinished ();  looking at the timeline panel shows that one of the those CALLS took an unusually long time. Figure 2 is a call to each function SummaryFigure Profile Panel. The table gives the inclusive and exclusive times and their percentages. Exclusive time is the function itself Basic Operationsnot includedThe time of the child function call). Inclusive time is the duration of the function call ( includeThe time of the child function call). Column 1: "Name" indicates the function name. By double-clicking the function name, you can see that the upper half of the interface is the time axis (Timeline panel) to see his time period. (marked with a coarse line). Double-click the function name to the left of the +"When you expand, you can see that the function's" Parentsand Children" column 2: "incl%" indicates the function's Inclusive TimeIn the whole methodtracingTime accounted for percentageColumn 3: "Inclusive" means Inclusive TimeColumn 4: "excl%" indicates the function's Exclusive TimeIn the whole methodtracingTime accounted for percentageColumn 5: "Exclusive" means Exclusive TimeColumn 6: "Calls+recurcalls/total" indicates the function's number of callsincluding recursive calls)。 The 2 nativefinished () that is listed as "14+0" represents 14 non-recursive calls and 0 recursive calls. Column 7: the new version (e.g. 2.1) and "Time/calls" indicate the average call time (i.e. inclusive time/total calls). 3. Figure 2 from Google Docs feels old. Note: If function A calls function B then function A is called "parents" of function B, and function B is called "Children" of function A.

Here is the translation

English Chinese
Incl Call method Elapsed Time Percentage
Inclusive Call method Time (MS) (including calls to all methods)
Excl Percentage of execution method occupation time
Exclusive Execution method Elapsed Time (ms) (not including calls to child methods)
Calls+recur Calls/total Number of calls and repeated calls
Time/call Total time (MS)
Figure 2Profile Panel Figure 3Profile Panel   second, Android more than 2.2 (including 2.2) version of the simplified use of traceview. Android 2.2, in addition to using traceview like 2.1, can also use TraceView in Ddms, much simpler than before. * The trace log files is streamed directly to your development machine. You can use the SD card after Android 2.2. The TraceView file stream is directed directly to the host that is developing the debug (that is, the computer where Ddms is located) to Start method profiling:1. The Devices tab, select the process so you want t   o Enable method profiling for.   2. Click the Start Method Profiling button.   3. Interact with your application-to-start the methods that's want to profile. 4. Click the Stop Method Profiling button. DDMS stops profiling your application and opens Traceview with the method profiling information it was collected between The time clicked on Start method Profiling and Stop method Profiling. How to do TraceView in DDMS. 1, in the device table selectedYou want to do the method trace. Process2, click the Method Profiling button to Start method trace. The button is at the top left of the window, which is on the left side of the stop button, just below the device menu. 3, Method Trace in Progress4, click the method Profiling button to stop method trace. The system automatically pops up the TraceView window to display the method trace results just now. iii.. traceview file FormatFor TraceView file format please refer to http://developer.android.com/guide/developing/debugging/debugging-tracing.html This article Reference source:/http wbdban.javaeye.com/blog/564309http://developer.android.com/guide/developing/debugging/ Debugging-tracing.htmlhttp://developer.android.com/guide/developing/debugging/ddms.html#profiling

Original: http://www.cnblogs.com/devinzhang/archive/2011/12/18/2291592.html

TraceView of Android Debugging Tools

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.