Merge "Systrace doc updates" into klp-docs
This commit is contained in:
committed by
Android (Google) Code Review
commit
de4a8d851b
BIN
docs/html/images/systrace/systrace-button.png
Normal file
BIN
docs/html/images/systrace/systrace-button.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
@@ -1,4 +1,5 @@
|
||||
page.title=Analyzing Display and Performance with Systrace
|
||||
page.title=Analyzing Display and Performance
|
||||
page.tags=systrace,speed
|
||||
parent.title=Debugging
|
||||
parent.link=index.html
|
||||
@jd:body
|
||||
@@ -12,10 +13,11 @@ parent.link=index.html
|
||||
<li><a href="#generate">Generating Traces</a>
|
||||
<ol>
|
||||
<li><a href="#limit-trace">Limiting trace data</a></li>
|
||||
<li><a href="#config-categories">Configuring trace data categories</a></li>
|
||||
<li><a href="#running">Running a trace</a></li>
|
||||
<li><a href="#running-4.3">Tracing on Android 4.3 and higher</a>
|
||||
<li><a href="#running-4.2">Tracing on Android 4.2 and lower</a></li>
|
||||
</ol>
|
||||
</li>
|
||||
<li><a href="#app-trace">Tracing Application Code</a></li>
|
||||
<li><a href="#analysis">Analyzing Traces</a>
|
||||
<ol>
|
||||
<li><a href="#long-processes">Long running processes</a></li>
|
||||
@@ -25,13 +27,12 @@ parent.link=index.html
|
||||
</ol>
|
||||
<h2>See also</h2>
|
||||
<ol>
|
||||
<li><a href="{@docRoot}tools/help/systrace.html">Systrace</a>
|
||||
</li>
|
||||
<li><a href="{@docRoot}tools/help/systrace.html">Systrace</a></li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p>After building features, eliminating bugs and cleaning up your code, you should spend some
|
||||
<p>After building features, eliminating bugs, and cleaning up your code, you should spend some
|
||||
time looking at the performance of your application. The speed and smoothness with which your
|
||||
application draws pixels and performs operations has an significant impact on your users'
|
||||
experience.</p>
|
||||
@@ -42,21 +43,21 @@ parent.link=index.html
|
||||
threaded processes for resources, which can cause performance problems that are hard to diagnose.
|
||||
</p>
|
||||
|
||||
<p>The {@code systrace} tool allows you to collect and review code execution data for your
|
||||
<p>The Systrace tool allows you to collect and review code execution data for your
|
||||
application and the Android system. You can use this data to diagnose execution problems and
|
||||
improve the performance of your application.</p>
|
||||
|
||||
|
||||
<h2 id="overview">Overview</h2>
|
||||
|
||||
<p>{@code systrace} helps you analyze how the execution of your application fits into the larger
|
||||
<p>Systrace helps you analyze how the execution of your application fits into the larger
|
||||
Android environment, letting you see system and applications process execution on a common
|
||||
timeline. The tool allows you to generate highly detailed, interactive reports from devices
|
||||
running Android 4.1 and higher, such as the report in figure 1.</p>
|
||||
|
||||
<img src="{@docRoot}images/systrace/report.png" alt="Systrace example report" id="figure1" />
|
||||
<p class="img-caption">
|
||||
<strong>Figure 1.</strong> An example {@code systrace} report on 5 seconds of process execution
|
||||
<strong>Figure 1.</strong> An example Systrace report on 5 seconds of process execution
|
||||
for a running application and related Android system processes.
|
||||
</p>
|
||||
|
||||
@@ -64,16 +65,21 @@ parent.link=index.html
|
||||
<h2 id="generate">Generating Traces</h2>
|
||||
|
||||
<p>In order to create a trace of your application, you must perform a few setup steps. First, you
|
||||
must have a device running Android 4.1 or higher. Setup the device for
|
||||
must have a device running Android 4.1 or higher. Set up the device for
|
||||
<a href="{@docRoot}tools/device.html#setting-up">debugging</a>, connect it to your development
|
||||
system and install your application. Some types of trace information, specifically disk activity
|
||||
and kernel work queues, require root access to the device, but most {@code systrace} log data
|
||||
only requires that the device be enabled for developer debugging.</p>
|
||||
system, and install your application. Some types of trace information, specifically disk activity
|
||||
and kernel work queues, require that you have root access to the device. However, most Systrace
|
||||
log data only requires that the device be enabled for developer debugging.</p>
|
||||
|
||||
<p>Systrace traces can be run either from a
|
||||
<a href="{@docRoot}tools/help/systrace.html#options">command line</a> or from a
|
||||
<a href="{@docRoot}tools/help/systrace.html#gui">graphical user interface</a>. This guide
|
||||
focuses on using the command line options.</p>
|
||||
|
||||
|
||||
<h3 id="limit-trace">Limiting trace data</h3>
|
||||
|
||||
<p>The {@code systrace} tool can generate a potentially huge amount of data from applications
|
||||
<p>The Systrace tool can generate a potentially huge amount of data from applications
|
||||
and system sources. To limit the amount of data the tool collects and make the data more relevant
|
||||
to your analysis, use the following options:</p>
|
||||
|
||||
@@ -81,39 +87,68 @@ parent.link=index.html
|
||||
<li>Limit the amount of time covered by the trace with the {@code -t, --time} option. The default
|
||||
length of a trace is 5 seconds.</li>
|
||||
<li>Limit the size of the data collected by the trace with the {@code -b, --buf-size} option.</li>
|
||||
<li>Specify what types of processes are traced using the {@code --set-tags} option and the
|
||||
{@code --disk}, {@code --cpu-freq}, {@code --cpu-idle}, {@code --cpu-load} options.</li>
|
||||
<li>Specify what types of processes are traced. The types of processes that can be traced depends
|
||||
on the version of Android you are running:
|
||||
<ul>
|
||||
<li>Android 4.2 and lower devices: Use the {@code --set-tags} option and the {@code --disk},
|
||||
{@code --cpu-freq}, {@code --cpu-idle}, {@code --cpu-load} options.</li>
|
||||
<li>Android 4.3 and higher devices: Use the {@code --list-categories} option to see what
|
||||
categories are available on your test device.</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h3 id="config-categories">Configuring trace data categories</h3>
|
||||
<h3 id="running-4.3">Tracing on Android 4.3 and higher</h3>
|
||||
|
||||
<p>To use {@code systrace} effectively, you must specify the types of processes you want to trace.
|
||||
<p>To run a trace on Android 4.3 and higher devices:</p>
|
||||
|
||||
<ol>
|
||||
<li>Make sure the device is connected through a USB cable and is
|
||||
<a href="{@docRoot}tools/device.html#setting-up">enabled for debugging</a>.</li>
|
||||
<li>Run the trace with the options you want, for example:
|
||||
<pre>
|
||||
$ cd android-sdk/platform-tools/systrace
|
||||
$ python systrace.py --time=10 -o mynewtrace.html sched gfx view wm
|
||||
</pre>
|
||||
</li>
|
||||
<li>On the device, execute any user actions you want be included in the trace.</li>
|
||||
</ol>
|
||||
|
||||
<p>For more information on the available options for running Systrace, see the
|
||||
<a href="{@docRoot}tools/help/systrace.html#options-4.3">Systrace</a> help page.</p>
|
||||
|
||||
|
||||
<h3 id="running-4.2">Tracing on Android 4.2 and lower</h3>
|
||||
|
||||
<p>To use Systrace effectively with devices running Android 4.2 and lower,
|
||||
you must configure the types of processes you want to trace before running a trace.
|
||||
The tool can gather the following types of process information:</p>
|
||||
|
||||
<ul>
|
||||
<li>General system processes such as graphics, audio and input processes (selected using trace
|
||||
<a href="{@docRoot}tools/help/systrace.html#tags">Tags</a>).</li>
|
||||
<a href="{@docRoot}tools/help/systrace.html#tags">category tags</a>).</li>
|
||||
<li>Low level system information such as CPU, kernel and disk activity (selected using
|
||||
<a href="{@docRoot}tools/help/systrace.html#options">Options</a>).</li>
|
||||
<a href="{@docRoot}tools/help/systrace.html#options">options</a>).</li>
|
||||
</ul>
|
||||
|
||||
<p>To set trace tags for {@code systrace} using the command-line:</p>
|
||||
<p>To set trace tags for Systrace using the command-line:</p>
|
||||
|
||||
<ol>
|
||||
<li>Use the {@code --set-tags} option:
|
||||
<pre>
|
||||
$> python systrace.py --set-tags=gfx,view,wm
|
||||
$ cd android-sdk/platform-tools/systrace
|
||||
$ python systrace.py --set-tags=gfx,view,wm
|
||||
</pre>
|
||||
</li>
|
||||
<li>Stop and restart the {@code adb} shell to enable tracing of these processes.
|
||||
<pre>
|
||||
$> adb shell stop
|
||||
$> adb shell start
|
||||
$ adb shell stop
|
||||
$ adb shell start
|
||||
</pre></li>
|
||||
</ol>
|
||||
|
||||
<p>To set trace tags for {@code systrace} using the device user interface:</p>
|
||||
<p>To set trace tags for Systrace using the device user interface:</p>
|
||||
|
||||
<ol>
|
||||
<li>On the device connected for tracing, navigate to: <strong>Settings >
|
||||
@@ -126,9 +161,6 @@ $> adb shell start
|
||||
selecting trace tags using this method.
|
||||
</p>
|
||||
|
||||
|
||||
<h3 id="running">Running a trace</h3>
|
||||
|
||||
<p>After you have configured the category tags for your trace, you can start collecting
|
||||
information for analysis.</p>
|
||||
|
||||
@@ -139,21 +171,77 @@ $> adb shell start
|
||||
<a href="{@docRoot}tools/device.html#setting-up">enabled for debugging</a>.</li>
|
||||
<li>Run the trace with the low-level system trace options and limits you want, for example:
|
||||
<pre>
|
||||
$> python systrace.py --cpu-freq --cpu-load --time=10 -o mytracefile.html
|
||||
$ python systrace.py --cpu-freq --cpu-load --time=10 -o mytracefile.html
|
||||
</pre>
|
||||
</li>
|
||||
<li>On the device, execute any user actions you want be included in the trace.</li>
|
||||
</ol>
|
||||
|
||||
<p>For more information on the available options for running Systrace, see the
|
||||
<a href="{@docRoot}tools/help/systrace.html#options-pre-4.3">Systrace</a> help page.</p>
|
||||
|
||||
|
||||
<h2 id="app-trace">Tracing Application Code</h2>
|
||||
|
||||
<p>The Systrace tool can trace the execution of code within your application. In Android
|
||||
4.3 (API level 18) and higher, you can use the methods of the {@link android.os.Trace} class to
|
||||
add instrumentation to your application code and see the results in a Systrace report.</p>
|
||||
|
||||
<p>The following code example shows how to use the {@link android.os.Trace} class to track
|
||||
execution of an application method, including two nested code blocks within that method.</p>
|
||||
|
||||
<pre>
|
||||
public void ProcessPeople() {
|
||||
Trace.beginSection("ProcessPeople");
|
||||
try {
|
||||
Trace.beginSection("Processing Jane");
|
||||
try {
|
||||
// code for Jane task...
|
||||
} finally {
|
||||
Trace.endSection(); // ends "Processing Jane"
|
||||
}
|
||||
|
||||
Trace.beginSection("Processing John");
|
||||
try {
|
||||
// code for John task...
|
||||
} finally {
|
||||
Trace.endSection(); // ends "Processing John"
|
||||
}
|
||||
} finally {
|
||||
Trace.endSection(); // ends "ProcessPeople"
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
<p class="note">
|
||||
<strong>Note:</strong> When you nest trace calls within each other, the
|
||||
{@link android.os.Trace#endSection} method ends the most recently called
|
||||
{@link android.os.Trace#beginSection} method. This means that a trace started within another
|
||||
trace cannot extend beyond the end of the enclosing trace, so make sure your beginning and
|
||||
ending method calls are properly matched to measure your applications processing.
|
||||
</p>
|
||||
|
||||
<p class="note">
|
||||
<strong>Note:</strong> Traces must begin and end on the same thread. Do not call
|
||||
{@link android.os.Trace#beginSection} on one thread of execution and then attempt to end the
|
||||
trace with a call to {@link android.os.Trace#endSection} on another thread.
|
||||
</p>
|
||||
|
||||
<p>When using application-level tracing with Systrace, you must specify the package name of your
|
||||
application in the user interface or specify the {@code -a} or {@code --app=} options on the
|
||||
command line. For more information, see the
|
||||
<a href="{@docRoot}tools/help/systrace.html">Systrace</a> help page.</p>
|
||||
|
||||
<!-- todo: add ndk coverage -->
|
||||
|
||||
|
||||
<h2 id="analysis">Analyzing Traces</h2>
|
||||
|
||||
<p>After you have generated a trace using {@code systrace}, it lists the location of the output
|
||||
<p>After you have generated a trace using Systrace, it lists the location of the output
|
||||
file and you can open the report using a web browser.
|
||||
How you use the trace data depends on the performance issues you are investigating. However,
|
||||
this section provides some general instructions on how to analyze a trace.</p>
|
||||
|
||||
<p>The reports generated by {@code systrace} are interactive, allowing you to zoom into and out of
|
||||
<p>The reports generated by Systrace are interactive, allowing you to zoom into and out of
|
||||
the process execution details. Use the <em>W</em> key to zoom in, the <em>S</em>
|
||||
key to zoom out, the <em>A</em> key to pan left and the <em>D</em> key to pan
|
||||
right. Select a task in timeline using your mouse to get more information about the task.
|
||||
@@ -193,7 +281,7 @@ id="figure2" />
|
||||
|
||||
<h3 id="display-interupts">Interruptions in display execution</h3>
|
||||
|
||||
<p>The {@code systrace} tool is particularly useful in analyzing application display slowness,
|
||||
<p>The Systrace tool is particularly useful in analyzing application display slowness,
|
||||
or pauses in animations, because it shows you the execution of your application across multiple
|
||||
system processes. With display execution, drawing screen frames with a regular rhythm is essential
|
||||
for good performance. Having a regular rhythm for display ensures that animations and motion are
|
||||
@@ -201,7 +289,7 @@ id="figure2" />
|
||||
from the users perspective.</p>
|
||||
|
||||
<p>If you are analyzing an application for this type of problem, examine the
|
||||
<strong>SurfaceFlinger</strong> process in the {@code systrace} report where your application is
|
||||
<strong>SurfaceFlinger</strong> process in the Systrace report where your application is
|
||||
also executing to look for places where it drops out of its regular rhythm.</p>
|
||||
|
||||
<img src="{@docRoot}images/systrace/display-rhythm.png" alt="Systrace exerpt of display processing"
|
||||
@@ -231,9 +319,9 @@ id="figure3" />
|
||||
</p>
|
||||
|
||||
<p class="note">
|
||||
<strong>Note:</strong> When using {@code systrace} to analyze display problems, make sure
|
||||
<strong>Note:</strong> When using Systrace to analyze display problems, make sure
|
||||
you activate the tracing tags for <strong>Graphics</strong> and <strong>Views</strong>.
|
||||
</p>
|
||||
|
||||
<p>For more information on the command line options and keyboard controls for {@code systrace},
|
||||
see the <a href="{@docRoot}tools/help/systrace.html">Systrace</a> reference page.</p>
|
||||
<p>For more information on the command line options and keyboard controls for Systrace,
|
||||
see the <a href="{@docRoot}tools/help/systrace.html">Systrace</a> help page.</p>
|
||||
@@ -15,13 +15,14 @@ page.title=Device Monitor
|
||||
|
||||
<p>Android Device Monitor is a stand-alone tool that provides a graphical user interface for
|
||||
several Android application debugging and analysis tools. The Monitor tool does not
|
||||
require installation of a integrated development environment, such as Eclipse, and encapsulates the
|
||||
require installation of an integrated development environment, such as Eclipse, and encapsulates the
|
||||
following tools:</p>
|
||||
|
||||
<ul>
|
||||
<li><a href="{@docRoot}tools/debugging/ddms.html">DDMS</a></li>
|
||||
<li><a href="gltracer.html">Tracer for OpenGL ES</a></li>
|
||||
<li><a href="hierarchy-viewer.html">Hierarchy Viewer</a></li>
|
||||
<li><a href="systrace.html">Systrace</a></li>
|
||||
<li><a href="traceview.html">Traceview</a></li>
|
||||
<li>Pixel Perfect magnification viewer</li>
|
||||
</ul>
|
||||
|
||||
@@ -4,47 +4,135 @@ parent.link=index.html
|
||||
@jd:body
|
||||
|
||||
|
||||
<p>The {@code systrace} tool helps analyze the performance of your application by capturing and
|
||||
<p>The Systrace tool helps analyze the performance of your application by capturing and
|
||||
displaying execution times of your applications processes and other Android system processes. The
|
||||
tool combines data from the Android kernel such as the CPU scheduler, disk activity and
|
||||
tool combines data from the Android kernel such as the CPU scheduler, disk activity, and
|
||||
application threads to generate an HTML report that shows an overall picture of an Android
|
||||
device’s system processes for a given period of time.</p>
|
||||
|
||||
<p>The {@code systrace} tool is particularly useful in diagnosing display problems where an
|
||||
<p>The Systrace tool is particularly useful in diagnosing display problems where an
|
||||
application is slow to draw or stutters while displaying motion or animation. For more information
|
||||
on how to use {@code systrace}, see <a href="{@docRoot}tools/debugging/systrace.html">Analyzing
|
||||
Display and Performance with Systrace</a>.</p>
|
||||
on how to use Systrace, see <a href="{@docRoot}tools/debugging/systrace.html">Analyzing
|
||||
Display and Performance</a>.</p>
|
||||
|
||||
|
||||
<h2 id="usage">Usage</h2>
|
||||
|
||||
<p>In order to run {@code systrace}, the {@code adb} tool and
|
||||
<a href="http://www.python.org/">Python</a> must be installed and included in your development
|
||||
<h2 id="requirements">Requirements</h2>
|
||||
|
||||
<p>In order to run Systrace, you must have Android SDK Tools 20 or later installed. You must also
|
||||
have <a href="http://www.python.org/">Python</a> installed and included in your development
|
||||
computer's execution path. In order to generate a trace, you must connect a device running Android
|
||||
4.1 (API Level 16) or higher to your development system using a USB debugging connection.</p>
|
||||
4.1 (API Level 16) or higher to your development system using a
|
||||
<a href="{@docRoot}tools/device.html#setting-up">USB debugging connection</a>.</p>
|
||||
|
||||
<p>The syntax for running {@code systrace} is as follows.</p>
|
||||
<p>The Systrace tool can be run either from one of the Android SDK's graphical user interface
|
||||
tools, or from the command line. The following sections describe how to run the tool using either
|
||||
of these methods.</p>
|
||||
|
||||
|
||||
<h2 id="gui">User Interface</h2>
|
||||
|
||||
<p>The Systrace tool can be run from the
|
||||
<a href="{@docRoot}tools/help/adt.html">Android Developer Tools</a> (ADT) in Eclipse,
|
||||
<a href="{@docRoot}sdk/installing/studio.html">Android Studio</a>,
|
||||
or the Android <a href="{@docRoot}tools/help/monitor.html">Device Monitor</a>.
|
||||
|
||||
<p>To run the Systrace user interface:</p>
|
||||
|
||||
<div class="toggle-content closed">
|
||||
<p style="margin-top:5px"><a href="#" onclick="return toggleContent(this)">
|
||||
<img src="/assets/images/triangle-closed.png" class="toggle-content-img" alt=""
|
||||
/>Using Eclipse</a></p>
|
||||
|
||||
<div class="toggle-content-toggleme">
|
||||
<ol>
|
||||
<li>In Eclipse, open an Android application project.</li>
|
||||
<li>Switch to the DDMS perspective, by selecting <strong>Window > Perspectives >
|
||||
DDMS</strong>.</li>
|
||||
<li>In the <strong>Devices</strong> tab, select the device on which to run a trace. If no
|
||||
devices are listed, make sure your device is connected via USB cable and that debugging is
|
||||
enabled on the device.</li>
|
||||
<li>Click the Systrace icon <img src="{@docRoot}images/systrace/systrace-button.png"
|
||||
style="margin:0"/> at the top of the <strong>Devices</strong> panel to configure tracing.</li>
|
||||
<li>Set the tracing options and click <strong>OK</strong> to start the trace.</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="toggle-content closed">
|
||||
<p style="margin-top:5px"><a href="#" onclick="return toggleContent(this)">
|
||||
<img src="/assets/images/triangle-closed.png" class="toggle-content-img" alt=""
|
||||
/>Using Android Studio</a></p>
|
||||
|
||||
<div class="toggle-content-toggleme">
|
||||
<ol>
|
||||
<li>In <a href="{@docRoot}sdk/installing/studio.html">Android Studio</a>, open an
|
||||
Android application project.</li>
|
||||
<li>Open the Device Monitor by selecting <strong>Tools > Android > Monitor</strong>.</li>
|
||||
<li>In the <strong>Devices</strong> tab, select the device on which to run a trace. If no
|
||||
devices are listed, make sure your device is connected via USB cable and that debugging is
|
||||
enabled on the device.</li>
|
||||
<li>Click the Systrace icon <img src="{@docRoot}images/systrace/systrace-button.png"
|
||||
style="margin:0"/> at the top of the <strong>Devices</strong> panel to configure tracing.</li>
|
||||
<li>Set the tracing options and click <strong>OK</strong> to start the trace.</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="toggle-content closed">
|
||||
<p style="margin-top:5px"><a href="#" onclick="return toggleContent(this)">
|
||||
<img src="/assets/images/triangle-closed.png" class="toggle-content-img" alt=""
|
||||
/>Using Device Monitor</a></p>
|
||||
|
||||
<div class="toggle-content-toggleme">
|
||||
<ol>
|
||||
<li>Navigate to your SDK {@code tools/} directory.</li>
|
||||
<li>Run the {@code monitor} program.</li>
|
||||
<li>In the <strong>Devices</strong> tab, select the device on which to run a trace. If no
|
||||
devices are listed, make sure your device is connected via USB cable and that debugging is
|
||||
enabled on the device.</li>
|
||||
<li>Click the Systrace icon <img src="{@docRoot}images/systrace/systrace-button.png"
|
||||
style="margin:0"/> at the top of the <strong>Devices</strong> panel to configure tracing.</li>
|
||||
<li>Set the tracing options and click <strong>OK</strong> to start the trace.</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<h2 id="options">Command Line Usage</h2>
|
||||
|
||||
<p>The Systrace tool has different command line options for devices running Android 4.3 (API
|
||||
level 18) and higher versus devices running Android 4.2 (API level 17) and lower. The following
|
||||
sections describe the different command line options for each version.</p>
|
||||
|
||||
<p>The general syntax for running Systrace from the command line is as follows.</p>
|
||||
|
||||
<pre>
|
||||
$> python systrace.py [options]
|
||||
$ python systrace.py [options] [category1] [category2] ... [categoryN]
|
||||
</pre>
|
||||
|
||||
<p>Here is an example execution run that sets trace tags and generates a trace from a connected
|
||||
Android device.</p>
|
||||
<p>See the sections below for example Systrace sessions.</p>
|
||||
|
||||
|
||||
<h3 id="options-4.3">Android 4.3 and higher options</h3>
|
||||
|
||||
<p>When you use Systrace on devices running Android 4.3 and higher, you must specify at least one
|
||||
trace category tag. Here is an example execution run that sets trace tags and generates a trace
|
||||
from a connected device.</p>
|
||||
|
||||
<pre>
|
||||
$> cd <em>android-sdk</em>/tools/systrace
|
||||
$> python systrace.py --set-tags gfx,view,wm
|
||||
$> adb shell stop
|
||||
$> adb shell start
|
||||
$> python systrace.py --disk --time=10 -o mynewtrace.html
|
||||
$ cd <em>android-sdk</em>/platform-tools/systrace
|
||||
$ python systrace.py --time=10 -o mynewtrace.html sched gfx view wm
|
||||
</pre>
|
||||
|
||||
<p class="note">
|
||||
<strong>Tip:</strong> If you want to see the names of tasks in the trace output, you <em>must</em>
|
||||
include the {@code sched} category in your command parameters.
|
||||
</p>
|
||||
|
||||
|
||||
<h2 id="options">Options</h2>
|
||||
|
||||
<p>The table below lists the command line options for {@code systrace}.</p>
|
||||
<p>The table below lists the Systrace command line options for devices running Android 4.3
|
||||
(API level 18) and higher.</p>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
@@ -53,6 +141,12 @@ $> python systrace.py --disk --time=10 -o mynewtrace.html
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><nobr><code>-h, --help</code></nobr></td>
|
||||
|
||||
<td>Show the help message.</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><code>-o <<em>FILE</em>></code></td>
|
||||
|
||||
@@ -62,14 +156,155 @@ $> python systrace.py --disk --time=10 -o mynewtrace.html
|
||||
<tr>
|
||||
<td><code>-t N, --time=N</code></td>
|
||||
|
||||
<td>Trace activity for N seconds. Default value is 5 seconds.</td>
|
||||
<td>Trace activity for <em>N</em> seconds. The default value is 5 seconds.</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><code>-b N, --buf-size=N</code></td>
|
||||
|
||||
<td>Use a trace buffer size of N kilobytes. This option lets you limit the total size of the
|
||||
data collected during a trace.</td>
|
||||
<td>Use a trace buffer size of <em>N</em> kilobytes. This option lets you limit the total size
|
||||
of the data collected during a trace.</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><code>-k <<em>KFUNCS</em>><br>
|
||||
--ktrace=<<em>KFUNCS</em>></code></td>
|
||||
|
||||
<td>Trace the activity of specific kernel functions, specified in a comma-separated list.</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><code>-l, --list-categories</code></td>
|
||||
|
||||
<td>List the available tracing category tags. The available tags are:
|
||||
|
||||
<ul>
|
||||
<li><code>gfx</code> - Graphics</li>
|
||||
<li><code>input</code> - Input</li>
|
||||
<li><code>view</code> - View</li>
|
||||
<li><code>webview</code> - WebView</li>
|
||||
<li><code>wm</code> - Window Manager</li>
|
||||
<li><code>am</code> - Activity Manager</li>
|
||||
<li><code>audio</code> - Audio</li>
|
||||
<li><code>video</code> - Video</li>
|
||||
<li><code>camera</code> - Camera</li>
|
||||
<li><code>hal</code> - Hardware Modules</li>
|
||||
<li><code>res</code> - Resource Loading</li>
|
||||
<li><code>dalvik</code> - Dalvik VM</li>
|
||||
<li><code>rs</code> - RenderScript</li>
|
||||
<li><code>sched</code> - CPU Scheduling</li>
|
||||
<li><code>freq</code> - CPU Frequency</li>
|
||||
<li><code>membus</code> - Memory Bus Utilization</li>
|
||||
<li><code>idle</code> - CPU Idle</li>
|
||||
<li><code>disk</code> - Disk input and output</li>
|
||||
<li><code>load</code> - CPU Load</li>
|
||||
<li><code>sync</code> - Synchronization Manager</li>
|
||||
<li><code>workq</code> - Kernel Workqueues</li>
|
||||
</ul>
|
||||
|
||||
<p class="note"><strong>Note:</strong> Some trace categories are not supported on all
|
||||
devices.</p>
|
||||
|
||||
<p class="note"><strong>Tip:</strong> If you want to see the names of tasks in the trace
|
||||
output, you <em>must</em> include the {@code sched} category in your command parameters.</p>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><code>-a <<em>APP_NAME</em>><br>
|
||||
--app=<<em>APP_NAME</em>></code></td>
|
||||
|
||||
<td>Enable tracing for applications, specified as a comma-separated list of
|
||||
<a href="{@docRoot}guide/topics/manifest/manifest-element.html#package">package names</a>.
|
||||
The apps must contain tracing instrumentation calls from the {@link android.os.Trace} class.
|
||||
For more information, see <a href="{@docRoot}tools/debugging/systrace.html#app-trace">Analyzing
|
||||
Display and Performance</a>.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
<tr>
|
||||
<td><code>--link-assets</code></td>
|
||||
|
||||
<td>Link to the original CSS or JavaScript resources instead of embedding them in the HTML
|
||||
trace report.</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><code>--from-file=<<em>FROM_FILE</em>></code></td>
|
||||
|
||||
<td>Create the interactive Systrace report from a file, instead of running a live trace.</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><code>--asset-dir=<<em>ASSET_DIR</em>></code></td>
|
||||
|
||||
<td>Specify a directory for the trace report assets. This option is useful for maintaining a
|
||||
single set of assets for multiple Systrace reports.</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td style="white-space:nowrap">
|
||||
<code>-e <<em>DEVICE_SERIAL</em>><br>
|
||||
--serial=<<em>DEVICE_SERIAL</em>></code></td>
|
||||
|
||||
<td>Conduct the trace on a specific connected device, identified by its
|
||||
<a href="{@docRoot}tools/help/adb.html#devicestatus">device serial number</a>.</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
|
||||
<h3 id="options-pre-4.3">Android 4.2 and lower options</h3>
|
||||
|
||||
<p>Using Systrace on the command line with devices running Android 4.2 and lower is typically a
|
||||
two-step process. You must first set the trace tags you want to capture and then run the trace.
|
||||
Here is an example execution run that sets trace tags and generates a trace from a connected
|
||||
device.</p>
|
||||
|
||||
<pre>
|
||||
$ cd <em>android-sdk</em>/platform-tools/systrace
|
||||
$ python systrace.py --set-tags gfx,view,wm
|
||||
$ adb shell stop
|
||||
$ adb shell start
|
||||
$ python systrace.py --disk --time=10 -o mynewtrace.html
|
||||
</pre>
|
||||
|
||||
<p>The table below lists the Systrace command line options for devices running Android 4.2
|
||||
(API level 17) and lower.</p>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Option</th>
|
||||
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><nobr><code>-h, --help</code></nobr></td>
|
||||
|
||||
<td>Show the help message.</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><code>-o <<em>FILE</em>></code></td>
|
||||
|
||||
<td>Write the HTML trace report to the specified file.</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><code>-t N, --time=N</code></td>
|
||||
|
||||
<td>Trace activity for <em>N</em> seconds. The default value is 5 seconds.</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><code>-b N, --buf-size=N</code></td>
|
||||
|
||||
<td>Use a trace buffer size of <em>N</em> kilobytes. This option lets you limit the total size
|
||||
of the data collected during a trace.</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@@ -105,6 +340,12 @@ $> python systrace.py --disk --time=10 -o mynewtrace.html
|
||||
the rate of data flowing into the trace buffer.</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><nobr><code>-u, --bus-utilization</code></nobr></td>
|
||||
|
||||
<td>Trace the bus utilization levels. This option requires root access on the device.</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><code>-w, --workqueue</code></td>
|
||||
|
||||
@@ -122,13 +363,13 @@ $> python systrace.py --disk --time=10 -o mynewtrace.html
|
||||
<li><code>webview</code> - WebView</li>
|
||||
<li><code>wm</code> - Window Manager</li>
|
||||
<li><code>am</code> - Activity Manager</li>
|
||||
<li><code>sync</code> - Sync Manager</li>
|
||||
<li><code>sync</code> - Synchronization Manager</li>
|
||||
<li><code>audio</code> - Audio</li>
|
||||
<li><code>video</code> - Video</li>
|
||||
<li><code>camera</code> - Camera</li>
|
||||
</ul>
|
||||
<p class="note"><strong>Note:</strong> When setting trace tags from the command line, you
|
||||
must stop and restart the framework ({@code $> adb shell stop; adb shell start}) for the
|
||||
must stop and restart the framework ({@code $ adb shell stop; adb shell start}) for the
|
||||
tag tracing changes to take effect.</p>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -140,22 +381,16 @@ $> python systrace.py --disk --time=10 -o mynewtrace.html
|
||||
report.</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><nobr><code>-h, --help</code></nobr></td>
|
||||
|
||||
<td>Show the help message.</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<p>You can set the trace <a href="#tags">tags</a> for {@code systrace} with your device's user
|
||||
interface, by navigating to <strong>Settings > Developer options > Monitoring > Enable
|
||||
traces</strong>.</p>
|
||||
<p>You can set the trace <a href="#tags">tags</a> for Systrace on
|
||||
your Android 4.2 and lower device by navigating to <strong>Settings > Developer options >
|
||||
Monitoring > Enable traces</strong>.</p>
|
||||
|
||||
|
||||
<h2 id="viewing-options">Trace Viewing Shortcuts</h2>
|
||||
|
||||
<p>The table below lists the keyboard shortcuts that are available while viewing a {@code systrace}
|
||||
<p>The table below lists the keyboard shortcuts that are available while viewing a Systrace
|
||||
trace HTML report.</p>
|
||||
|
||||
<table>
|
||||
|
||||
@@ -138,7 +138,7 @@
|
||||
<li><a href="<?cs var:toroot ?>tools/debugging/improving-w-lint.html"><span class="en">Improving Your Code with lint</span></a></li>
|
||||
<li><a href="<?cs var:toroot ?>tools/debugging/debugging-ui.html"><span class="en">Optimizing your UI</span></a></li>
|
||||
<li><a href="<?cs var:toroot ?>tools/debugging/debugging-tracing.html"><span class="en">Profiling with Traceview and dmtracedump</span></a></li>
|
||||
<li><a href="<?cs var:toroot ?>tools/debugging/systrace.html"><span class="en">Analysing Display and Performance with Systrace</span></a></li>
|
||||
<li><a href="<?cs var:toroot ?>tools/debugging/systrace.html"><span class="en">Analyzing Display and Performance</span></a></li>
|
||||
<li><a href="<?cs var:toroot ?>tools/debugging/debugging-memory.html">Investigating Your RAM Usage</a></li>
|
||||
<li><a href="<?cs var:toroot ?>tools/debugging/debugging-devtools.html"><span class="en">Using the Dev Tools App</span></a></li>
|
||||
</ul>
|
||||
|
||||
Reference in New Issue
Block a user