Introduction to the Android Performance tuning tool

Source: Internet
Author: User

Traceview

TraceView is the graphical viewer for the execution log. These logs are logged by using the Debug class. TraceView can help debug application and profile performance.

TraceView layout

TraceView can load TRAC log files (added to the app by adding tracking code or generated by DDMS). The TraceView interface is divided into two parts, the Timeline Panel (time panel), which describes the start and stop times of each thread and method. Here is the profile panel, outlining what the method does, as shown in:

Time Line Panel:

Profile Panel:

Generate trace log

There are two ways to generate trace logs:
It is accurate to include the Debug class in your code and call its methods, such as startmethodtracing () and stopmethodtracing ().
Use the profile analysis feature of DDMS to generate trace logs. Less accurate, not able to access the application's code or use it without the need for precise recording time.

Note: If you use the Debug class, the application must have write permission to the external store (Write_external_storag??). E).

12345 // start tracing to "/sdcard/calc.trace"Debug.startMethodTracing("calc");// ...// stop tracingDebug.stopMethodTracing();

When the app calls Startmethodtracing (), the system creates a <trace-base-name>.trace file. This includes binary method trace data and thread and method name Mapping tables.

The system then starts buffering the generated trace data until the application calls Stopmethodtracing (), at which point its buffered data is written to the output file. If the maximum buffer size is reached before the system calls Stopmethodtracing, the system stops the trace and sends a notification to the console.

When you turn on profile, the interpreted code runs slower and does not represent the actual execution speed.

On Android 4.4 and later, sampling will reduce the performance impact. Use Startmethodtracingsampling () to stop using stopmethodtracing ().

Example execution:

1234567891011121314151617 C:\Users\Administrator>adb pull /mnt/sdcard/tc.trace /tmp/tc.traceC:\Users\Administrator>adb shell am start -n com.mamlambo.article.simplecalc/.MainActivityStarting: Intent { cmp=com.mamlambo.article.simplecalc/.MainActivity }C:\Users\Administrator>adb shell am profile com.mamlambo.article.simplecalc start /mnt/sdcard/tc.trace C:\Users\Administrator>adb shell am profile com.mamlambo.article.simplecalc stopC:\Users\Administrator>adb pull /mnt/sdcard/tc.trace /tmp/tc.trace1352KB/s (2429326bytes in1.754s)C:\Users\Administrator>traceview c:\tmp\tc.traceThe standalone version of traceview isdeprecated.Please use Android Device Monitor (tools/monitor) instead.

Note: If the mkdir failed for IMG read-only file system appears, execute Mount-o remount after executing the adb shell command, RW/CAN

Http://www.cnblogs.com/pythontesting/p/4935451.html

Introduction to the Android Performance Tuning tool (GO)

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.