From c468240c1a2a393ec02d992f459c6586ae450161 Mon Sep 17 00:00:00 2001
From: Scott Main When you have a trace log file (generated by adding tracing code to your application or by DDMS),
- you can have Traceview load the log files and display their data in a window visualizes your application
- in two panels:Traceview Layout
The image below shows a close up of the timeline panel. Each thread’s execution is shown +
Figure 1 shows a close up of the timeline panel. Each thread’s execution is shown
in its own row, with time increasing to the right. Each method is shown in another color (colors
are reused in a round-robin fashion starting with the methods that have the most inclusive time).
The thin lines underneath the first row show the extent (entry to exit) of all the calls to the
- selected method. The method in this case is LoadListener.nativeFinished() and it was selected in
- the profile view.
There are two ways to generate trace logs:
Before you start generating trace logs, be aware of the following restrictions:
This document focuses on using the {@link android.os.Debug} class to generate trace data. For more information on using DDMS @@ -134,22 +140,22 @@ parent.link=index.html Debug.stopMethodTracing(); -
When your application calls startMethodTracing(), the system creates a file called +
When your application calls {@link android.os.Debug#startMethodTracing() startMethodTracing()},
+ the system creates a file called
<trace-base-name>.trace. This contains the binary method trace data and a
mapping table with thread and method names.
The system then begins buffering the generated trace data, until your application calls - stopMethodTracing(), at which time it writes the buffered data to the output file. If the system - reaches the maximum buffer size before stopMethodTracing() is called, the system stops tracing + {@link android.os.Debug#stopMethodTracing() stopMethodTracing()}, at which time it writes + the buffered data to the output file. If the system + reaches the maximum buffer size before you call {@link android.os.Debug#stopMethodTracing() + stopMethodTracing()}, the system stops tracing and sends a notification to the console.
-Interpreted code will run more slowly when profiling is enabled. Don't try to generate - absolute timings from the profiler results (i.e. "function X takes 2.5 seconds to run"). The +
Interpreted code runs more slowly when profiling is enabled. Don't try to generate + absolute timings from the profiler results (such as, "function X takes 2.5 seconds to run"). The times are only useful in relation to other profile output, so you can see if changes have made - the code faster or slower.
- -When using the Android emulator, you must specify an SD card when you create your AVD because the trace files - are written to the SD card. Your application must have permission to write to the SD card as well. + the code faster or slower relative to a previous profiling run.
Figure 3. Screenshot of dmtracedump
+Figure 3. Screenshot of dmtracedump
For each node, dmtracedump shows <ref>
callname (<inc-ms>, <exc-ms>,<numcalls>), where