• No results found

Using dmtracedump

In document Developing In Eclipse, with ADT (Page 136-139)

0x080f630c android/os/Debug startMethodTracing ()V 0x080f6350 android/os/Debug startMethodTracing (Ljava/lang/String;Ljava/lang/String;I)V

*end

version section

The first line is the file version number, currently 1. The second line, clock=global, indicates that we use a common clock across all threads. A future version may use per-thread CPU time counters that are independent for every thread.

threads section

One line per thread. Each line consists of two parts: the thread ID, followed by a tab, followed by the thread name.

There are few restrictions on what a valid thread name is, so include everything to the end of the line.

methods section

One line per method entry or exit. A line consists of four pieces, separated by tab marks: method-ID [TAB] class-name [TAB] method-class-name [TAB] signature . Only the methods that were actually entered or exited are included in the list. Note that all three identifiers are required to uniquely identify a method.

Neither the threads nor methods sections are sorted.

Traceview Known Issues

Threads

Traceview logging does not handle threads well, resulting in these two problems:

If a thread exits during profiling, the thread name is not emitted;

1.

The VM reuses thread IDs. If a thread stops and another starts, they may get the same ID.

2.

Using dmtracedump

The Android SDK includes dmtracedump, a tool that gives you an alternate way of generating graphical call-stack diagrams from trace log files. The tool uses the Graphviz Dot utility to create the graphical output, so you need to install Graphviz before running dmtracedump.

The dmtracedump tool generates the call stack data as a tree diagram, with each call represented as a node. It shows call flow (from parent node to child nodes) using arrows. The diagram below shows an example of dmtracedump output.

Page 5 of 7 Traceview: A Graphical Log Viewer | Android Developers

9/7/2010

file://V:\android-sdk-windows\docs\guide\developing\tools\traceview.html

For each node, dmtracedump shows <ref> callname (<inc-ms>, <exc-ms>,<numcalls>), where

<ref> -- Call reference number, as used in trace logs

<inc-ms> -- Inclusive elapsed time (milliseconds spent in method, including all child methods)

<exc-ms> -- Exclusive elapsed time (milliseconds spent in method, not including any child methods)

<numcalls> -- Number of calls

The usage for dmtracedump is:

dmtracedump [-ho] [-s sortable] [-d trace-base-name] [-g outfile] <trace-base-name>

The tool then loads trace log data from <trace-base-name>.data and <trace-base-name>.key. The table below lists the options for dmtracedump.

Page 6 of 7 Traceview: A Graphical Log Viewer | Android Developers

9/7/2010

file://V:\android-sdk-windows\docs\guide\developing\tools\traceview.html

↑ Go to top

Option Description

-d <trace-base-name>

Diff with this trace name

-g <outfile> Generate output to <outfile>

-h Turn on HTML output

-o Dump the trace file instead of profiling -d

<trace-base-name>

URL base to the location of the sortable javascript file

-t <percent> Minimum threshold for including child nodes in the graph (child's inclusive time as a percentage of parent inclusive time). If this option is not used, the default threshold is 20%.

Except as noted, this content is licensed under Apache 2.0. For details and restrictions, see the Content License.

Android 2.2 r1 - 14 May 2010 15:20

Site Terms of Service - Privacy Policy - Brand Guidelines

Page 7 of 7 Traceview: A Graphical Log Viewer | Android Developers

9/7/2010

file://V:\android-sdk-windows\docs\guide\developing\tools\traceview.html

↑ Go to top

zipalign

zipalign is an archive alignment tool that provides important optimization to Android application (.apk) files. The purpose is to ensure that all uncompressed data starts with a particular alignment relative to the start of the file. Specifically, it causes all uncompressed data within the .apk, such as images or raw files, to be aligned on 4-byte boundaries. This allows all portions to be accessed directly with mmap() even if they contain binary data with alignment restrictions. The benefit is a reduction in the amount of RAM consumed when running the application.

This tool should always be used to align your .apk file before distributing it to end-users. The Android build tools can handle this for you. When using Eclipse with the ADT plugin, the Export Wizard will automatically zipalign your .apk after it signs it with your private key. The build scripts used when compiling your application with Ant will also zipalign

your .apk, as long as you have provided the path to your keystore and the key alias in your project build.properties file, so that the build tools can sign the package first.

Caution: zipalign must only be performed after the .apk file has been signed with your private key. If you perform zipalign before signing, then the signing procedure will undo the alignment. Also, do not make alterations to the aligned package. Alterations to the archive, such as renaming or deleting entries, will potentially disrupt the alignment of the modified entry and all later entries. And any files added to an "aligned" archive will not be aligned.

The adjustment is made by altering the size of the "extra" field in the zip Local File Header sections. Existing data in the

"extra" fields may be altered by this process.

For more information about how to use zipalign when building your application, please read Signing Your Application.

Usage

To align infile.apk and save it as outfile.apk:

zipalign [-f] [-v] <alignment> infile.apk outfile.apk

To confirm the alignment of existing.apk:

zipalign -c -v <alignment> existing.apk

The <alignment> is an integer that defines the byte-alignment boundaries. This must always be 4 (which provides 32-bit alignment) or else it effectively does nothing.

Flags:

-f : overwrite existing outfile.zip

-v : verbose output

-c : confirm the alignment of the given file

Except as noted, this content is licensed under Apache 2.0. For details and restrictions, see the Content License.

Android 2.2 r1 - 14 May 2010 15:20

Site Terms of Service - Privacy Policy - Brand Guidelines

Page 1 of 1 zipalign | Android Developers

9/7/2010

file://V:\android-sdk-windows\docs\guide\developing\tools\zipalign.html

In document Developing In Eclipse, with ADT (Page 136-139)