# 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.
没有合适的资源?快使用搜索试试~ 我知道了~
QT-Android NDK+OpenSSL.rar
共2000个文件
h:1449个
py:530个
txt:11个
需积分: 0 1 下载量 85 浏览量
2024-03-28
19:32:03
上传
评论
收藏 845.48MB RAR 举报
温馨提示
资源得分批上传,这里是android-ndk-r20b-windows-x86_64.zip 和android_openssl-master.zip OpenSSL暂时没有用。
资源推荐
资源详情
资源评论
收起资源包目录
QT-Android NDK+OpenSSL.rar (2000个子文件)
pdb.doc 8KB
vulkan_core.h 440KB
NdkCameraMetadataTags.h 402KB
NeuralNetworks.h 283KB
gl2ext.h 213KB
gl32.h 125KB
OpenMAXAL.h 107KB
gl31.h 105KB
zlib.h 85KB
gl3.h 81KB
OpenSLES.h 80KB
eglext.h 63KB
glext.h 52KB
nl80211.h 51KB
jni.h 51KB
unicodeobject.h 51KB
input.h 50KB
AAudio.h 48KB
videodev2.h 48KB
NdkCameraDevice.h 48KB
v4l2-controls.h 45KB
abstract.h 44KB
gl2.h 43KB
binder_parcel.h 41KB
NdkCameraCaptureSession.h 39KB
object.h 38KB
pyconfig.h 36KB
pyport.h 36KB
kvm.h 35KB
NdkImage.h 31KB
gl.h 31KB
asound.h 31KB
pci_regs.h 31KB
binder_parcel_utils.h 30KB
glibc-syscalls.h 30KB
sensor.h 30KB
keycodes.h 29KB
zorro_ids.h 28KB
v4l2-dv-timings.h 28KB
NdkCaptureRequest.h 27KB
soundcard.h 27KB
radeon_drm.h 27KB
i915_drm.h 26KB
configuration.h 26KB
nameser.h 25KB
ethtool.h 23KB
ib_user_verbs.h 23KB
NdkImageReader.h 23KB
binder_ibinder.h 22KB
nf_tables.h 21KB
NdkMediaDrm.h 21KB
hardware_buffer.h 21KB
Python-ast.h 21KB
cec.h 20KB
sysctl.h 20KB
drm.h 19KB
queue.h 19KB
input-event-codes.h 18KB
pkt_sched.h 18KB
NdkCameraManager.h 18KB
btrfs.h 18KB
unistd-common.h 18KB
if_link.h 18KB
amdgpu_drm.h 18KB
sctp.h 18KB
NdkMediaCodec.h 18KB
bpf.h 17KB
icmp6.h 17KB
ch9.h 17KB
unistd_x32.h 16KB
unistd_x32.h 16KB
OpenSLES_Android.h 16KB
cdrom.h 16KB
surface_control.h 16KB
Platform.h 15KB
egl.h 15KB
pthread.h 15KB
zconf.h 15KB
rtnetlink.h 15KB
math.h 14KB
elf.h 14KB
objimpl.h 14KB
perf_event.h 14KB
video.h 14KB
keyboard.h 13KB
asequencer.h 13KB
wireless.h 13KB
drm_mode.h 13KB
stdatomic.h 13KB
fc_els.h 13KB
NdkMediaFormat.h 13KB
cdefs.h 13KB
btrfs_tree.h 12KB
audit.h 12KB
unistd.h 12KB
stdio.h 12KB
openvswitch.h 12KB
asoc.h 12KB
native_activity.h 12KB
coda.h 11KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
ypp240124016
- 粉丝: 451
- 资源: 24
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功