1-性能分析-android-systrace

一:Systrace简介

systrace是Android4.1版本之后推出的,对系统Performance分析的工具。可帮助开发者收集 Android 关键子系统(如 SurfaceFlinger/SystemServer/Kernel/Input/Display 等 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目录/sdk/platform-tools/systrace中,其内部将调用atrace程序)用来配置数据采集的方式(如采集数据的标签、输出文件名等)和收集ftrace统计数据并生成一个结果网页文件供用户查看。从本质上说,Systrace 是对 Linux Kernel中 ftrace 的封装。应用进程需要利用 Android 提供的 Trace 类来使用 Systrace

二: Systrace 简单使用

1> Systrace.py 介绍

Systrace.py在 Android-SDK 目录下的 platform-tools 里面 ;android-sdk/platform-tools/systrace/systrace.py
另外 User 版本所抓的 Systrce 文件所包含的信息,是比 eng 版本或者 Userdebug 版本要少的,建议使用 Userdebug 版本的机器来进行 debug,这样既保证了性能,又能有比较详细的输出结果

1. Systrace.py -h

format:
Usage: systrace.py [options] [category1 [category2 …]]
Example:
systrace.py -b 32768 -t 15 gfx input view sched freq

systrace Options introduce
-h, --help show this help message and exit
-o FILE write trace output to FILE
-j, --json write a JSON file
–link-assets (deprecated)
–asset-dir=ASSET_DIR (deprecated)
-e DEVICE_SERIAL_NUMBER, --serial=DEVICE_SERIAL_NUMBER adb device serial number
–target=TARGET choose tracing target (android or linux)
–timeout=TIMEOUT timeout for start and stop tracing (seconds)
–collection-timeout=COLLECTION_TIMEOUT timeout for data collection (seconds)
-t N, --time=N trace for N seconds
-b N, --buf-size=N use a trace buffer size of N KB
-l, --list-categories list the available categories and exit
Atrace options introduce
–atrace-categories=ATRACE_CATEGORIES Select atrace categories with a comma-delimited list,e.g. --atrace-categories=cat1,cat2,cat3
-k KFUNCS, --ktrace=KFUNCS specify a comma-separated list of kernel functions to trace
–no-compress Tell the device not to send the trace data in compressed form
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

45度看我

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值