自 2025 年 3 月 27 日起,我们建议您使用 android-latest-release
而非 aosp-main
构建 AOSP 并为其做出贡献。如需了解详情,请参阅 AOSP 的变更。
系统性能工具
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
本页介绍了可用于衡量性能指标的工具。
启动时间
如需分析启动时间,请使用 Simpleperf 文档。请使用 config.yaml
文件添加要搜索的事件。config.yaml
应如下所示:
stop_event: <logcat log message which will terminate log collection after reboot>
events:
event1_name: <pattern that matches log message>
event2_
...
在某些设备上,启动时钟后,前几秒内显示的时间可能有误。尽管 bootanalyze 工具可以在开箱后进行时间校正,但您可以在 config.yaml
中提供可选的时间校正模式。
优化启动时间一文介绍了如何使用引导加载程序、设备内核、I/O 调整、启动动画和 SELinux 政策等组件缩短启动时间。
应用启动时间
用户希望应用能够及时响应并快速加载。应用启动时间一文详细介绍了启动过程的内部机制,并讨论了如何分析并优化启动性能。
界面
界面 (UI) 性能测试旨在确保以下事项:您的应用满足功能要求、用户与应用之间的互动顺畅无比、您的应用能够持续以每秒 60 帧(请参阅 Android 性能模式:为什么选择 60fps?)的帧速运行,而且完全不会出现帧丢失或帧延迟的现象。
如需了解详情,请参阅测试界面性能和 JankTest。
内存
您可以通过以下两种方法之一检查应用的内存用量:
- 如需查看一段时间的内存用量,请使用
procstats
。
- 检查查看某个时间点的内存用量,请使用
meminfo
。
如需了解详情,请参阅:
- 如需衡量内存用量,请参阅查看内存分配。
- 为了使用 Android Studio IDE 检查内存,Android Studio 提供了一个基于 GUI 的内存使用情况工具。如需了解详情,请参阅使用内存分析器查看 Java 堆和内存分配情况。
- 如需在 Linux、Android 和 Chrome 平台上以及用户空间应用中进行性能检测和跟踪,请使用开源 Perfetto。
中央处理器
您可以使用以下工具查询 CPU。
- 如需对在 Android 设备上运行的 Android 应用和原生进程进行分析,请使用 Simpleperf 文档。
一款适用于 Android 的原生中央处理器 (CPU) 性能分析工具。Simpleperf 可以剖析 Android 上的 Java 和 C++ 代码。Simpleperf 可执行文件可在高于 Android L 的版本上运行,而 Python 脚本可在高于 Android N 的版本上使用。
Simpleperf 文档。
如需了解详情,请参阅 Simpleperf 文档。
- 如需在与应用交互时实时检查应用的 CPU 使用率和线程活动,请使用 CPU 性能剖析器。这样做能带来诸多好处,如提供更快、更顺畅的用户体验,以及延长设备电池续航时间。此外,您还可以检查记录的方法跟踪数据、函数跟踪数据和系统跟踪数据的详情。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# System performance tools\n\nThis page describes the tools you can use to measure performance metrics.\n\nBoot time\n---------\n\nTo profile boot timing, use the\n[Simpleperf](https://android.googlesource.com/platform/system/extras/+/android16-release/simpleperf/doc/README.md)\ndocumentation.\n`config.yaml` file to include events you want to search for. `config.yaml`\nshould appear as follows: \n\n```scdoc\n stop_event: \u003clogcat log message which will terminate log collection after reboot\u003e\n events:\n event1_name: \u003cpattern that matches log message\u003e\n event2_\n ...\n```\n\nOn some devices, booting the clock may display an incorrect time for the first few seconds. While\nthe bootanalyze tool can accommodate a time correction out-of-the-box, you can provide an optional\ntime correction pattern in `config.yaml`.\n[Optimizing boot times](/devices/tech/perf/boot-times) explains how to improve boot\ntime using components such as Bootloader, Device Kernel, I/O tuning, Boot animation, and the\nSELinux policy.\n\nApp start-up time\n-----------------\n\nUsers expect apps to be quick to load and responsive.\n[App Startup Time](https://developer.android.com/topic/performance/vitals/launch-time)\ndetails the internals of the launch process and discusses how to profile and optimize startup\nperformance.\n\nUser interface\n--------------\n\nUser interface (UI) performance testing ensures that your app meets functional requirements and\nthat user interactions with your app are smooth, run at a consistent 60 frames per second (see\n[Android\nPerformance Patterns: Why 60fps?](https://www.youtube.com/watch?v=CaMTIgxCSqU&index=25&list=PLWz5rJ2EKKc9CBxr3BVjPTPoDPLdPIFCE)), and all without dropping or delaying frames.\n\nFor more information, see [Test\nUI Performance](https://developer.android.com/training/testing/performance) and\n[JankTest](https://developer.android.com/reference/android/support/test/jank/JankTest).\n\nMemory\n------\n\nYou can inspect app memory usage in one of two ways:\n\n- Over time, using `procstats`.\n- Snapshot in time, using `meminfo`.\n\nFor details, see:\n\n- To measure memory usage, see [View\n Memory Allocations](https://developer.android.com/studio/command-line/dumpsys.html#ViewingAllocations).\n- To use the Android Studio IDE to inspect memory, Android Studio provides a GUI-based memory usage tool. For details, see [View the Java Heap and\n Memory Allocations with Memory Profiler](https://developer.android.com/studio/profile/memory-profiler).\n- To conduct performance instrumentation and tracing on the Linux, Android, and Chrome platform and in user-space apps, use open source [Perfetto](https://perfetto.dev/#/).\n\nCentral processing unit\n-----------------------\n\nYou can use the following tools to query the CPU.\n\n- To profile Android apps *and* native processes running on Android, use [Simpleperf](https://android.googlesource.com/platform/system/extras/+/android16-release/simpleperf/doc/README.md) documentation.\na native central processing unit (CPU) profiling tool for Android. Simpleperf can profile Java and C++ code on Android. The Simpleperf executable can run on Android releases later than L and Python scripts can be used on Android releases later than N. \n\n[Simpleperf](https://android.googlesource.com/platform/system/extras/+/android16-release/simpleperf/doc/README.md) documentation. For details, see the [Simpleperf](https://android.googlesource.com/platform/system/extras/+/android16-release/simpleperf/doc/README.md) documentation.\n- To inspect your app's CPU usage and thread activity in real time while interacting with your app, use the [CPU Profiler](https://developer.android.com/studio/profile/cpu-profiler). Doing so has many advantages, such as providing a faster and smoother user experience and preserving device battery life. In addition, you can inspect the details of recorded method, function, and system traces."]]