# Simpleperf
Simpleperf is a native profiling tool for Android. It can be used to profile
both Android applications and native processes running on Android. It can
profile both Java and C++ code on Android. It can be used on Android L
and above.
Simpleperf is part of the Android Open Source Project. The source code is [here](https://android.googlesource.com/platform/system/extras/+/master/simpleperf/).
The latest document is [here](https://android.googlesource.com/platform/system/extras/+/master/simpleperf/doc/README.md).
## Table of Contents
- [Introduction](#introduction)
- [Tools in simpleperf](#tools-in-simpleperf)
- [Android application profiling](#android-application-profiling)
- [Prepare an Android application](#prepare-an-android-application)
- [Record and report profiling data](#record-and-report-profiling-data)
- [Record and report call graph](#record-and-report-call-graph)
- [Report in html interface](#report-in-html-interface)
- [Show flame graph](#show-flame-graph)
- [Record both on CPU time and off CPU time](#record-both-on-cpu-time-and-off-cpu-time)
- [Profile from launch](#profile-from-launch)
- [Parse profiling data manually](#parse-profiling-data-manually)
- [Android platform profiling](#android-platform-profiling)
- [Executable commands reference](#executable-commands-reference)
- [How simpleperf works](#how-simpleperf-works)
- [Commands](#commands)
- [The list command](#the-list-command)
- [The stat command](#the-stat-command)
- [Select events to stat](#select-events-to-stat)
- [Select target to stat](#select-target-to-stat)
- [Decide how long to stat](#decide-how-long-to-stat)
- [Decide the print interval](#decide-the-print-interval)
- [Display counters in systrace](#display-counters-in-systrace)
- [The record command](#the-record-command)
- [Select events to record](#select-events-to-record)
- [Select target to record](#select-target-to-record)
- [Set the frequency to record](#set-the-frequency-to-record)
- [Decide how long to record](#decide-how-long-to-record)
- [Set the path to store profiling data](#set-the-path-to-store-profiling-data)
- [Record call graphs](#record-call-graphs-in-record-cmd)
- [Record both on CPU time and off CPU time](#record-both-on-cpu-time-and-off-cpu-time-in-record-cmd)
- [The report command](#the-report-command)
- [Set the path to read profiling data](#set-the-path-to-read-profiling-data)
- [Set the path to find binaries](#set-the-path-to-find-binaries)
- [Filter samples](#filter-samples)
- [Group samples into sample entries](#group-samples-into-sample-entries)
- [Report call graphs](#report-call-graphs-in-report-cmd)
- [Scripts reference](#scripts-reference)
- [app_profiler.py](#app_profiler-py)
- [Profile from launch of an application](#profile-from-launch-of-an-application)
- [run_simpleperf_without_usb_connection.py](#run_simpleperf_without_usb_connection-py)
- [binary_cache_builder.py](#binary_cache_builder-py)
- [run_simpleperf_on_device.py](#run_simpleperf_on_device-py)
- [report.py](#report-py)
- [report_html.py](#report_html-py)
- [inferno](#inferno)
- [pprof_proto_generator.py](#pprof_proto_generator-py)
- [report_sample.py](#report_sample-py)
- [simpleperf_report_lib.py](#simpleperf_report_lib-py)
- [Answers to common issues](#answers-to-common-issues)
- [Why we suggest profiling on android >= N devices](#why-we-suggest-profiling-on-android-n-devices)
- [Suggestions about recording call graphs](#suggestions-about-recording-call-graphs)
- [How to solve missing symbols in report](#how-to-solve-missing-symbols-in-report)
- [Bugs and contribution](#bugs-and-contribution)
## Introduction
Simpleperf contains two parts: the simpleperf executable and Python scripts.
The simpleperf executable works similar to linux-tools-perf, but has some specific features for
the Android profiling environment:
1. It collects more info in profiling data. Since the common workflow is "record on the device, and
report on the host", simpleperf not only collects samples in profiling data, but also collects
needed symbols, device info and recording time.
2. It delivers new features for recording.
a. When recording dwarf based call graph, simpleperf unwinds the stack before writing a sample
to file. This is to save storage space on the device.
b. Support tracing both on CPU time and off CPU time with --trace-offcpu option.
c. Support recording callgraphs of JITed and interpreted Java code on Android >= P.
3. It relates closely to the Android platform.
a. Is aware of Android environment, like using system properties to enable profiling, using
run-as to profile in application's context.
b. Supports reading symbols and debug information from the .gnu_debugdata section, because
system libraries are built with .gnu_debugdata section starting from Android O.
c. Supports profiling shared libraries embedded in apk files.
d. It uses the standard Android stack unwinder, so its results are consistent with all other
Android tools.
4. It builds executables and shared libraries for different usages.
a. Builds static executables on the device. Since static executables don't rely on any library,
simpleperf executables can be pushed on any Android device and used to record profiling data.
b. Builds executables on different hosts: Linux, Mac and Windows. These executables can be used
to report on hosts.
c. Builds report shared libraries on different hosts. The report library is used by different
Python scripts to parse profiling data.
Detailed documentation for the simpleperf executable is [here](#executable-commands-reference).
Python scripts are split into three parts according to their functions:
1. Scripts used for recording, like app_profiler.py, run_simpleperf_without_usb_connection.py.
2. Scripts used for reporting, like report.py, report_html.py, inferno.
3. Scripts used for parsing profiling data, like simpleperf_report_lib.py.
Detailed documentation for the Python scripts is [here](#scripts-reference).
## Tools in simpleperf
The simpleperf executables and Python scripts are located in simpleperf/ in ndk releases, and in
system/extras/simpleperf/scripts/ in AOSP. Their functions are listed below.
bin/: contains executables and shared libraries.
bin/android/${arch}/simpleperf: static simpleperf executables used on the device.
bin/${host}/${arch}/simpleperf: simpleperf executables used on the host, only supports reporting.
bin/${host}/${arch}/libsimpleperf_report.${so/dylib/dll}: report shared libraries used on the host.
[app_profiler.py](#app_profiler-py): recording profiling data.
[run_simpleperf_without_usb_connection.py](#run_simpleperf_without_usb_connection-py):
recording profiling data while the USB cable isn't connected.
[binary_cache_builder.py](#binary_cache_builder-py): building binary cache for profiling data.
[report.py](#report-py): reporting in stdio interface.
[report_html.py](#report_html-py): reporting in html interface.
[inferno.sh](#inferno) (or inferno.bat on Windows): generating flamegraph in html interface.
inferno/: implementation of inferno. Used by inferno.sh.
[pprof_proto_generator.py](#pprof_proto_generator-py): converting profiling data to the format
used by [pprof](https://github.com/google/pprof).
[report_sample.py](#report_sample-py): converting profiling data to the format used by [FlameGraph](https://github.com/brendangregg/FlameGraph).
[simpleperf_report_lib.py](#simpleperf_report_lib-py): library for parsing profiling data.
## Android application profiling
This section shows how to profile an Android application.
Some examples are [Here](https://android.googlesource.com/platform/system/extras/+/master/simpleperf/demo/README.
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
android-ndk-r18b-windows-x86_64.zip (12346个子文件)
aarch64-linux-android-ld.1 121KB
x86_64-linux-android-ld.1 121KB
i686-linux-android-ld.1 121KB
arm-linux-androideabi-ld.1 121KB
aarch64-linux-android-as.1 77KB
x86_64-linux-android-as.1 77KB
i686-linux-android-as.1 77KB
arm-linux-androideabi-as.1 77KB
aarch64-linux-android-objcopy.1 50KB
x86_64-linux-android-objcopy.1 50KB
i686-linux-android-objcopy.1 50KB
arm-linux-androideabi-objcopy.1 50KB
aarch64-linux-android-objdump.1 35KB
x86_64-linux-android-objdump.1 35KB
i686-linux-android-objdump.1 35KB
arm-linux-androideabi-objdump.1 35KB
aarch64-linux-android-gprof.1 30KB
x86_64-linux-android-gprof.1 30KB
i686-linux-android-gprof.1 30KB
arm-linux-androideabi-gprof.1 30KB
aarch64-linux-android-dlltool.1 20KB
x86_64-linux-android-dlltool.1 20KB
i686-linux-android-dlltool.1 20KB
arm-linux-androideabi-dlltool.1 20KB
aarch64-linux-android-ar.1 19KB
x86_64-linux-android-ar.1 19KB
i686-linux-android-ar.1 19KB
arm-linux-androideabi-ar.1 19KB
aarch64-linux-android-nm.1 17KB
x86_64-linux-android-nm.1 17KB
i686-linux-android-nm.1 17KB
arm-linux-androideabi-nm.1 17KB
aarch64-linux-android-strip.1 15KB
x86_64-linux-android-strip.1 15KB
i686-linux-android-strip.1 15KB
arm-linux-androideabi-strip.1 15KB
aarch64-linux-android-readelf.1 15KB
x86_64-linux-android-readelf.1 15KB
i686-linux-android-readelf.1 15KB
arm-linux-androideabi-readelf.1 15KB
python2.7.1 14KB
python.1 14KB
python2.1 14KB
aarch64-linux-android-windres.1 13KB
x86_64-linux-android-windres.1 13KB
i686-linux-android-windres.1 13KB
arm-linux-androideabi-windres.1 13KB
aarch64-linux-android-c++filt.1 11KB
x86_64-linux-android-c++filt.1 11KB
i686-linux-android-c++filt.1 11KB
arm-linux-androideabi-c++filt.1 11KB
aarch64-linux-android-strings.1 11KB
x86_64-linux-android-strings.1 11KB
i686-linux-android-strings.1 11KB
arm-linux-androideabi-strings.1 11KB
aarch64-linux-android-addr2line.1 11KB
x86_64-linux-android-addr2line.1 11KB
i686-linux-android-addr2line.1 11KB
arm-linux-androideabi-addr2line.1 11KB
aarch64-linux-android-windmc.1 10KB
x86_64-linux-android-windmc.1 10KB
i686-linux-android-windmc.1 10KB
arm-linux-androideabi-windmc.1 10KB
scan-build.1 10KB
aarch64-linux-android-size.1 9KB
x86_64-linux-android-size.1 9KB
i686-linux-android-size.1 9KB
arm-linux-androideabi-size.1 9KB
aarch64-linux-android-elfedit.1 8KB
x86_64-linux-android-elfedit.1 8KB
i686-linux-android-elfedit.1 8KB
arm-linux-androideabi-elfedit.1 8KB
aarch64-linux-android-nlmconv.1 8KB
x86_64-linux-android-nlmconv.1 8KB
i686-linux-android-nlmconv.1 8KB
arm-linux-androideabi-nlmconv.1 8KB
aarch64-linux-android-ranlib.1 7KB
x86_64-linux-android-ranlib.1 7KB
i686-linux-android-ranlib.1 7KB
arm-linux-androideabi-ranlib.1 7KB
libc++.a.16 65B
libc++.so.16 56B
libc++.a.16 47B
libc++.so.16 38B
libc++.a.17 65B
libc++.so.17 56B
libc++.a.17 47B
libc++.so.17 38B
libc++.a.18 65B
libc++.so.18 56B
libc++.a.18 47B
libc++.so.18 38B
libc++.a.19 65B
libc++.so.19 56B
libc++.a.19 47B
libc++.so.19 38B
libc++.a.20 65B
libc++.so.20 56B
libc++.a.20 47B
libc++.so.20 38B
共 12346 条
- 1
- 2
- 3
- 4
- 5
- 6
- 124
资源评论
- 爱你爱我2021-01-26还是不错的,已经下载
xkx2008
- 粉丝: 1
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功