本文大部分内容来自:http://www.androidperformance.com/android-performance-tools-systrace-1.html?utm_source=tuicool

  Systrace是Android4.1中新增的性能数据采样和分析工具。它可帮助开发者收集Android关键子系统(如surfaceflinger、WindowManagerService等Framework部分关键模块、服务,View系统等)的运行信息,从而帮助开发者更直观的分析系统瓶颈,改进性能。

Systrace的功能包括跟踪系统的I/O操作、内核工作队列、CPU负载以及Android各个子系统的运行状况等。在Android平台中,它主要由3部分组成:

  • 内核部分:Systrace利用了Linux Kernel中的ftrace功能。所以,如果要使用Systrace的话,必须开启kernel中和ftrace相关的模块。
  • 数据采集部分:Android定义了一个Trace类。应用程序可利用该类把统计信息输出给ftrace。同时,Android还有一个atrace程序,它可以从ftrace中读取统计信息然后交给数据分析工具来处理。
  • 数据分析工具:Android提供一个systrace.py(python脚本文件,位于Android SDK目录/tools/systrace中,其内部将调用atrace程序)用来配置数据采集的方式(如采集数据的标签、输出文件名等)和收集ftrace统计数据并生成一个结果网页文件供用户查看。 从本质上说,Systrace是对Linux Kernel中ftrace的封装。应用进程需要利用Android提供的Trace类来使用Systrace.

关于Systrace的官方介绍和使用可以看这里:Systrace

1.Systrace简单使用

使用Systrace前,要先了解一下Systrace在各个平台上的使用方法,鉴于大家使用Eclipse和Android Studio的居多,所以直接摘抄官网关于这个的使用方法,不过不管是什么工具,流程是一样的:

  • 手机准备好你要进行抓取的界面
  • 点击开始抓取(命令行的话就是开始执行命令)
  • 手机上开始操作
  • 设定好的时间到了之后,会将生成Trace文件,使用Chrome将这个文件打开进行分析

Using Eclipse

  1. In Eclipse, open an Android application project.
    1. Switch to the DDMS perspective, by selecting Window > Perspectives > DDMS.
    2. In the Devices 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.
    3. Click the Systrace icon at the top of the Devices panel to configure tracing.
    4. Set the tracing options and click OK to start the trace.

Using  Android Studio

  1. In Android Studio, open an Android application project.
    1. Open the Device Monitor by selecting Tools > Android > Monitor.
    2. In the Devices 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.
    3. Click the Systrace icon at the top of the Devices panel to configure tracing.
    4. Set the tracing options and click OK to start the trace.

Using Device Monitor

  1. Navigate to your SDK tools/ directory.
    1. Run the monitor program.
    2. In the Devices 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.
    3. Click the Systrace icon at the top of the Devices panel to configure tracing.
    4. Set the tracing options and click OK to start the trace.

图解:

首先进入DDMS,然后点击设备,点击Systrace按钮,接着选择测试项,这里可以设定时间。点击确定后开始操作手机,在时间到了后会自动生成报表。

参考自:

http://blog.csdn.net/tommy_wxie/article/details/8636853

http://www.androidperformance.com/android-performance-tools-systrace-1.html?utm_source=tuicool

Android性能优化工具之Systrace的更多相关文章

  1. Linux/Android 性能优化工具 perf

    /***************************************************************************** * Linux/Android 性能优化工 ...

  2. (转)Android性能优化——工具篇

    Android性能优化是Android开发中经常遇见的一个问题,接下来将对Android性能优化方面的知识点做一个简单的梳理和总结,将从工具和代码两方面进行梳理.所谓工欲善其事必先利其器,本文首先来看 ...

  3. android 性能优化-工具篇

    一.Traceview 使用TraceView主要有两种方式: 1.直接打开DDMS,选择一个进程,然后按上面的“Start Method Profiling”按钮,等红色小点变成黑色以后就表示Tra ...

  4. Android 性能优化之工具和优化点总结

    Android性能优化学习 最近公司主抓性能优化工作,借此春风也学习到了许多Android性能优化方面的知识.由于组内队友的给力,优化的成果也是比较喜人.同时也学习和实践了不少知识,特此记录. 1.性 ...

  5. 【腾讯Bugly干货分享】Android性能优化典范——第6季

    本文来自于腾讯bugly开发者社区,非经作者同意,请勿转载,原文地址:http://dev.qq.com/topic/580d91208d80e49771f0a07c 导语 这里是Android性能优 ...

  6. Android性能优化典范(二)

    Google前几天刚发布了Android性能优化典范第2季的课程,一共20个短视频,包括的内容大致有:电量优化,网络优化,Wear上如何做优化,使用对象池来提高效率,LRU Cache,Bitmap的 ...

  7. android app性能优化大汇总(google官方Android性能优化典范 - 第2季)

    Google前几天刚发布了Android性能优化典范第2季的课程,一共20个短视频,包括的内容大致有:电量优化,网络优化,Wear上如何做优化,使用对象池来提高效率,LRU Cache,Bitmap的 ...

  8. 正确使用Android性能分析工具——TraceView

    http://blog.jobbole.com/78995/     首页 最新文章 IT 职场 前端 后端 移动端 数据库 运维 其他技术 - 导航条 - 首页 最新文章 IT 职场 前端 - Ja ...

  9. Android性能优化典范 - 第2季

    Google发布了Android性能优化典范第2季的课程,一共20个短视频,包括的内容大致有:电量优化,网络优化,Wear上如何做优化,使用对象池来提高效率,LRU Cache,Bitmap的缩放,缓 ...

随机推荐

  1. Selenium Books

    Recently, some of my projects rely heavily upon tests with selenium. Some books about selenium are c ...

  2. [转] React 最佳实践——那些 React 没告诉你但很重要的事

    前言:对很多 react 新手来说,网上能找到的资源大都是些简单的 tutorial ,它们能教会你如何使用 react ,但并不会告诉你怎么在实际项目中优雅的组织和编写 react 代码.用谷歌搜中 ...

  3. 后缀自动机(SAM)速成手册!

    正好写这个博客和我的某个别的需求重合了...我就来讲一讲SAM啦qwq 后缀自动机,也就是SAM,是一种极其有用的处理字符串的数据结构,可以用于处理几乎任何有关于子串的问题,但以学起来异常困难著称(在 ...

  4. The web application [ ] registered the JDBC driver [net.sourceforge.jtds.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver

    出现以下错误时,我找了很多方法,都未解决,网上有很多,最后我实在无奈,怀疑会不会是Tomcat的原因,更换了一个版本之后就好了.The web application [ ] registered t ...

  5. 001.Parted工具使用

    一 Parted简介 1.1 parted和fdisk 通常使用较多的磁盘管理工具为fdisk,但由于磁盘越来越廉价,且磁盘空间越来越大,而fdisk工具分区存在大小限制,只能划分小于2T的磁盘.因此 ...

  6. 数据库简单练习 建表+select

    create table student ( sno int primary key, sname char(20),  sex char(2), birthday datetime, class i ...

  7. Java中static块执行时机

    Java中static块执行时机 演示例子 在使用static进行初始化的操作,怎么也执行不了!代码如下: public class StaticDemo { public static final ...

  8. 24.python中类的方法

    类中的方法,其实就是类中的函数,可以分为:实例方法,类方法,静态方法.方法和字段一样,也是属于类的属性,所以也具有运行中修改的特效, 但一般不推荐这样做. 我在类的基本语法中,介绍了构造器方法:__i ...

  9. HDU 5744 Keep On Movin 贪心

    Keep On Movin 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5744 Description Professor Zhang has k ...

  10. HDU 3979 Monster (贪心排序)

    Monster Time Limit: 10000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Su ...