Android 设备可以根据系统负载动态更改时钟设置。此行为对于在使用期间节省电量非常有帮助,但可能会导致难以获取可靠的性能数据。如果您尝试确定代码 fragment 的运行速度有多快以防止出现回归问题,或者如果优化可重复,那么如果未以固定的时钟速度进行测试,结果就会不可靠。借助固定的时钟,您可以准确地对性能进行 A/B 测试,而无需将 CPU 频率更改作为一项因素。
固定性能模式会设置 CPU 和 GPU 时钟的上限和下限。此模式不会停用其他动态性能行为,例如核心选择。
[[["易于理解","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-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."]]