固定性能模式
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
已发布:Android 11(API 级别 30)
Android 设备可以根据系统负载动态更改时钟设置。此行为对于在使用期间节省电量非常有帮助,但可能会导致难以获取可靠的性能数据。如果您尝试确定代码 fragment 的运行速度有多快以防止出现回归问题,或者如果优化可重复,那么如果未以固定的时钟速度进行测试,结果就会不可靠。借助固定的时钟,您可以准确地对性能进行 A/B 测试,而无需将 CPU 频率更改作为一项因素。
固定性能模式会设置 CPU 和 GPU 时钟的上限和下限。此模式不会停用其他动态性能行为,例如核心选择。
您可以使用以下 adb 命令启用固定性能模式:
adb shell cmd power set-fixed-performance-mode-enabled [true|false]
以固定性能模式运行的设备可能仍会过热,因为该模式并不会使设备进入热可持续状态。因此,我们建议在运行基准测试时执行以下操作:
- 等待设备返回到热可持续状态,然后再启动
。
- 在测试期间监控设备的热状态,以区分基准测试代码和热事件的影响。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[],[],null,["# Fixed Performance Mode\n\n**Released**: Android 11 (API level 30)\n\nAndroid devices can change clocking dynamically based on the system load. This\nbehavior is good for power savings during use, but can make it difficult to get\nreliable performance data. If you are trying to determine how fast a code\nfragment can run for regression prevention, or if an optimization is repeatable,\nyour results won't be reliable if they aren't tested at fixed clock speeds. With\nfixed clocks, you can do accurate A/B testing of performance without changes in\nthe CPU frequency being a factor.\n\nFixed-performance mode sets CPU and GPU clocks with an upper and lower bound.\nThis mode does not disable other dynamic performance behaviors, such as core\nselection.\n\nYou can enable fixed-performance mode with the following adb command: \n\n adb shell cmd power set-fixed-performance-mode-enabled [true|false]\n\nA device that is running in fixed-performance mode can still overheat because\nthe mode doesn't put the device into a thermally-sustainable state. Because of\nthis, we recommend the following for benchmark runs:\n\n- Wait for the device to return to a thermally-sustainable state before starting the run.\n- Monitor the thermal state of the device during testing to differentiate the impact between the benchmark code and thermal events."]]