How to analyze the Android Application Performance and Java function call relationships.
1. mksdcard-l sdcard 512 M/root/. Android/sdcard. img
2. Add the start and end functions of trace to the application (For details, refer to the development documentation)
// Start tracing to "/sdcard/Calc. Trace"
Debug. startmethodtracing ("calc"); -------- calc is the name of the. trace file to be generated
//..
// Stop Tracing
Log. D ("lizhenghui", "nnnnnnn stop traceview debug ");
Debug. stopmethodtracing ();
3. Specify the sdcard directory when the emulator starts under the "run Configuraton --> additional emulator command line options" option of the target item in Eclipse:-sdcard/root/. Android/sdcard. img
4. run Android from eclipse.
5. Exit the application and use logcat to check whether the preceding log information appears. Make sure that the trace file is not empty.
6. ADB ls/sdcard/
We can see a file: Calc. Trace is the file we need.
7. Download the trace file to your local device.
ADB pull/sdcard/Calc. Trace ./
8. Traceview Calc. Trace
Open the trace file, and take a look at the help document with patience. You can see that the top part of this file is divided into a time relationship diagram, reflecting the time at which the function is executed. The lower part is divided into a function relationship diagram, it reflects the call relationship of a function. Meanings of the following items:
Name: Lists All call items. The preceding number is the number. Expand to show that the parent and children subitems are called and called.
Incl: percentage of the time taken to calculate the total time.
Passive: time used by the call. (Including the call time of all sub-methods)
Excl: percentage of the total execution time.
Exclusive: execution time, excluding the time of the sub-method.
Cballs + recur cballs/Total: number of calls and repeated calls
Time/call: the total time. MS)
9. Generate a function call Relationship Diagram
A. APT-Get install graphviz
B. dmtacedump-G aa.png Calc. Trace
C. ls images generate aa.png images.
10. Use the image tool to open an image.
11. Function display format on the image (using the example in the development document, I am using a remote Internet)
<ref> callname (<inc-ms>, <exc-ms>,<numcalls>)
- Ref -- no.
callname
-- Function name
<Inc -- MS> -- call time
<exc-ms>
-- Execution time
<numcalls>
-- Number of calls