接触到了Android系统的Performance测试,因此有锁定CPU的需求:shell
因为要首先读取到此系统所支持的CPU频率,以后再所支持的频率中选取你想要的频率,以后进行锁定。测试
这个过程,手动也是能够的,直接:spa
1.查看所支持的CPU频率:code
adb shell cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequenciesorm
返回的结果是:416000 728000 900000 1040000blog
2.从上边的结果中选取一个416000 ,以后进行设定:token
echo 416000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
echo 416000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freqci
以后运行adb shell环境,输入rem
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freqinput
查看设置是否有效,假如一直是416000,则证实设置生效。
因为每次都要输入以上代码查看以后设置,因此考虑用自动化实现,代码以下:
setFrequence.bat文件:
@adb shell setprop persist.service.thermal 0 @adb wait-for-device @adb root @adb wait-for-device @adb remount @for /f "tokens=*" %%i in ('adb shell cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies') do @set var=%%i @echo All cpufreqs are: %var% @set /p last=please input your freq: ::@echo My cpufreq is: %last% @adb push .\run.sh /system/bin/ @adb shell chmod -R 777 /system/bin @adb shell /system/bin/run.sh --Cpufreq=%last%
run.sh文件:
#!system//bin/sh while [ $# -gt 0 ]; do case $1 in --Cpufreq=*) cpufreq=${1#--Cpufreq=} ;; esac shift done #echo cpufreq=`echo $cpufreq` echo $cpufreq > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq echo $cpufreq > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq echo $cpufreq > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq echo $cpufreq > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq echo scaling_min_freq=`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq` echo scaling_max_freq=`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq` echo scaling_cur_freq= i=10 while [[ $i -gt 1 ]]; do cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq; sleep 5; ((i--)); done
把上边两个文件放到一个folder下边,双击执行setFrequence.bat文件,输入你想要的频率便可。