android4.1~Systrace

来源:互联网 发布:brew install php fpm 编辑:程序博客网 时间:2024/06/10 02:27

你现在使用的是android4.1吗,如果不是,还等什么呢,赶快升级吧,更多新的特性等着你,现在就简单介绍一下我们在新版本开发中德新工具吧,原文:

Systrace

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 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.

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 systrace, see Analyzing Display and Performance with Systrace.

Usage


In order to run systrace, the adb tool and Python must be 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.

The syntax for running systrace is as follows.

$> python systrace.py [options]

Here is an example execution run that sets trace tags and generates a trace from a connected Android device.

$> cd android-sdk/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

Options


The table below lists the command line options for systrace.

OptionDescription-o <FILE>Write the HTML trace report to the specified file.-t N, --time=NTrace activity for N seconds. Default value is 5 seconds.-b N, --buf-size=NUse a trace buffer size of N kilobytes. This option lets you limit the total size of the data collected during a trace.-d, --diskTrace disk input and output activity. This option requires root access on the device.-f, --cpu-freqTrace CPU frequency changes. Only changes to the CPU frequency are logged, so the initial frequency of the CPU when tracing starts is not shown.-i, --cpu-idleTrace CPU idle events.-l, --cpu-loadTrace CPU load. This value is a percentage determined by the interactive CPU frequency governor.-s, --no-cpu-schedPrevent tracing of the CPU scheduler. This option allows for longer trace times by reducing the rate of data flowing into the trace buffer.-w, --workqueueTrace kernel work queues. This option requires root access on the device.--set-tags=<TAGS>Set the enabled trace tags in a comma separated list. The available tags are:
  • gfx - Graphics
  • input - Input
  • view - View
  • webview - WebView
  • wm - Window Manager
  • am - Activity Manager
  • sync - Sync Manager
  • audio - Audio
  • video - Video
  • camera - Camera

Note: When setting trace tags from the command line, you must stop and restart the framework ($> adb shell stop; adb shell start) for the tag tracing changes to take effect.

--link-assetsLink to the original CSS or JS resources instead of embedding them in the HTML trace report.-h, --helpShow the help message.

You can set the trace tags for systrace with your device's user interface, by navigating to Settings > Developer options > Monitoring > Enable traces.

Trace Viewing Shortcuts


The table below lists the keyboard shortcuts that are available while viewing a systrace trace HTML report.

KeyDescriptionwZoom into the trace timeline.sZoom out of the trace timeline.aPan left on the trace timeline.dPan right on the trace timeline.eCenter the trace timeline on the current mouse location.gShow grid at the start of the currently selected task.Shift+gShow grid at the end of the currently selected task.Right ArrowSelect the next event on the currently selected timeline.Left ArrowSelect the previous event on the currently selected timeline.Double ClickZoom into the trace timeline.Shift+Double ClickZoom out of the trace timeline.
上面介绍的很详细,简单描述可为系统操作的跟踪,你可以用它来更快的获取其系统运行时的相关状态,并找到相关问题,自己去尝试一下吧

原创粉丝点击