Created
April 29, 2022 18:01
-
-
Save dimorinny/bb8354389a1f5914641f449d91a8f4cb to your computer and use it in GitHub Desktop.
ro_benchmark.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eax | |
ITERATIONS=3 | |
declare -a BLOCK_SIZE_ARR=("4K" "64K" "256K" "1M") | |
drop_caches() { | |
adb shell 'echo 3 > proc/sys/vm/drop_caches' | |
} | |
raven_cpu_lock() | |
{ | |
adb shell setenforce 0 | |
adb root | |
for i in `seq 0 7` | |
do | |
CPUFREQ=/sys/devices/system/cpu/cpu$i/cpufreq | |
_cpumax $CPUFREQ | |
done | |
adb shell 'echo performance > /sys/class/devfreq/17000010.devfreq_mif/governor' | |
adb shell 'echo performance > /sys/class/devfreq/17000020.devfreq_int/governor' | |
adb shell 'echo bfq > /sys/block/sda/queue/scheduler' | |
adb shell 'echo 2 > /sys/block/sda/queue/rq_affinity' | |
adb shell 'echo 0 > /sys/block/sda/queue/iosched/slice_idle' | |
irq_path=`adb shell find /proc/irq | grep ufs` | |
adb shell "echo 8 > $irq_path/../smp_affinity" | |
} | |
_cpumax() | |
{ | |
max=`adb shell cat $1/cpuinfo_max_freq` | |
adb shell "echo performance > $1/scaling_governor" | |
adb shell "echo $max > $1/scaling_min_freq" | |
adb shell "echo $max > $1/scaling_max_freq" | |
} | |
redfin_cpu_lock() { | |
set +e | |
adb shell setenforce 0 | |
adb root | |
adb shell 'echo performance > /sys/class/kgsl/kgsl-3d0/devfreq/governor' | |
adb shell 'echo 625000000 > /sys/class/kgsl/kgsl-3d0/devfreq/max_freq' | |
# configure governor settings for little cluster | |
adb shell 'echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor' | |
adb shell 'echo 1728000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq' | |
# configure governor settings for big cluster | |
adb shell 'echo performance > /sys/devices/system/cpu/cpu6/cpufreq/scaling_governor' | |
adb shell 'echo 2323200 > /sys/devices/system/cpu/cpu6/cpufreq/scaling_max_freq' | |
# configure governor settings for big big CPU | |
adb shell 'echo performance > /sys/devices/system/cpu/cpu7/cpufreq/scaling_governor' | |
adb shell 'echo 2361600 > /sys/devices/system/cpu/cpu7/cpufreq/scaling_max_freq' | |
# configure driver/block layer setting | |
adb shell 'echo cfq > /sys/block/sda/queue/scheduler' | |
adb shell 'echo 2 > /sys/block/sda/queue/rq_affinity' | |
adb shell 'echo 0 > /sys/block/sda/queue/iosched/slice_idle' | |
set -e | |
} | |
fio() { | |
adb shell setenforce 0 | |
adb root | |
local mode="$1" | |
echo "Starting fio ${mode} benchmark" | |
for block_size in "${BLOCK_SIZE_ARR[@]}"; do | |
echo "==== Block size ${block_size} ====" | |
for i in $(seq ${ITERATIONS}); do | |
echo "==== Iteration ${i} ====" | |
drop_caches | |
sleep 3 | |
adb shell "/data/fio --rw=${mode} --ioengine=sync --bs=${block_size} --readonly --name=job1 --filename=/product/system_ext.img" | |
sleep 10 | |
done | |
done | |
} | |
main() { | |
local operation=$1 | |
local type=$2 | |
case $type in | |
redfin) redfin_cpu_lock;; | |
raven) raven_cpu_lock;; | |
mt6761) echo "CPU lock is not supported";; | |
*) echo "Unknow device type (redfin, raven and mt6761 are supported)" | |
esac | |
sleep 5 | |
case $operation in | |
fio-sequential) fio "read";; | |
fio-random) fio "randread";; | |
esac | |
} | |
main "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment