Adb命令给 Android CPU 提频 | 收藏,用的上

文摘   2024-10-29 07:30   广东  

在排查性能相关问题时,有时我们需要看下是否是cpu降频了之类的~,那么通过adb命令来查看和设置cpu频率就派上用场了。

设置CPU频率:

#!/bin/bash
echo "cpu 0 freq"adb shell "echo "userspace" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"adb shell "echo "1958400" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed"
echo "cpu 1 freq"  adb shell "echo "userspace" > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor"adb shell "echo "1958400" > /sys/devices/system/cpu/cpu1/cpufreq/scaling_setspeed"
echo "cpu 2 freq"  adb shell "echo "userspace" > /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor"adb shell "echo "1958400" > /sys/devices/system/cpu/cpu2/cpufreq/scaling_setspeed"
echo "cpu 3 freq"  adb shell "echo "userspace" > /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor"adb shell "echo "1958400" > /sys/devices/system/cpu/cpu3/cpufreq/scaling_setspeed"


查看当前cpu频率:

#!/bin/bash
for ((i=0;i<3000000;i++));do echo "\n\n========test cnt ${i}=======" echo "cpu 0 freq"   adb shell "cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq"
echo "cpu 1 freq"   adb shell "cat /sys/devices/system/cpu/cpu1/cpufreq/cpuinfo_cur_freq"
echo "cpu 2 freq"   adb shell "cat /sys/devices/system/cpu/cpu2/cpufreq/cpuinfo_cur_freq"
echo "cpu 3 freq"   adb shell "cat /sys/devices/system/cpu/cpu3/cpufreq/cpuinfo_cur_freq"
echo "cpu 4 freq"   adb shell "cat /sys/devices/system/cpu/cpu4/cpufreq/cpuinfo_cur_freq"
echo "cpu 5 freq"   adb shell "cat /sys/devices/system/cpu/cpu5/cpufreq/cpuinfo_cur_freq"done

cpufreq中参数说明:

scaling_setspeed–设置cpu运行的频率

cpuinfo_cur_freq–CPU当前运行的频率

cpuinfo_max_freq—CPU可以运行的最大频率

cpuinfo_min_freq—CPU最小运行频率

scaling_governor—控制CPU频率的调整方式


《Android Camera开发入门》、《Camx初认识》已经上架,可以点击了解 -> 小驰成长圈 |期待见证彼此的成长 



觉得不错,点个赞呗 

小驰行动派
前世界500强软件开发工程师,记录分享工作和生活的思考。感谢关注,期待见证彼此的成长~
 最新文章