Last active
March 23, 2022 05:18
-
-
Save jagogardiner/67ca5bae296948923b2d8a378219cec7 to your computer and use it in GitHub Desktop.
A dhrystone benchmark script I made for finding out dhrystones per frequency, which can be used to find CPU capacities.
This file contains hidden or 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/sh | |
# User tunables | |
# Number of cores in the system | |
coreno=8 | |
# Cores in the big cluster | |
bigcluster=4 | |
# Cores in the little cluster | |
littlecluster=4 | |
# Little cluster availiable frequencies | |
lcfreqs=(633600 902400 1113600 1401600 1536000 1747200 1843200) | |
# Big cluster availiable frequencies | |
bcfreqs=(1113600 1401600 1747200 1804800 1958400 2150400 2208000) | |
# Stop Android for accuracy and some services | |
function stopserv() { | |
stop | |
stop cameraserver | |
stop audioserver | |
stop bluetooth | |
stop thermal-engine | |
stop storaged | |
stop keystore | |
stop drmserver | |
stop logcat | |
stop mediaserver | |
stop servicemanager | |
stop qti | |
stop time_daemon | |
stop drmserver | |
stop portbridge | |
stop netmgrd | |
stop xtra-daemon | |
stop tombstoned | |
stop therm_core | |
stop wpa_supplicant | |
stop sensors.qti | |
stop perfprofd | |
stop lowi-server | |
stop imsqmidaemon | |
stop thermalserviced | |
stop rmt_storage | |
stop pm-service | |
stop healthd | |
stop vold | |
stop lmkd | |
stop pd-mapper | |
stop tftp_server | |
} | |
# Offline big cores | |
function offlinebig() { | |
for i in $(seq $((coreno - bigcluster)) $((coreno - 1))); do | |
chmod 777 /sys/devices/system/cpu/cpu$i/online | |
echo 0 > /sys/devices/system/cpu/cpu$i/online | |
done | |
} | |
# Offline little cores | |
function offlinelittle() { | |
for i in $(seq 0 $((littlecluster - 1))); do | |
chmod 777 /sys/devices/system/cpu/cpu$i/online | |
echo 0 > /sys/devices/system/cpu/cpu$i/online | |
done | |
} | |
# Online big cores | |
function onlinebig() { | |
for i in $(seq $((coreno - bigcluster)) $((coreno - 1))); do | |
chmod 777 /sys/devices/system/cpu/cpu$i/online | |
echo 1 > /sys/devices/system/cpu/cpu$i/online | |
done | |
} | |
# Online little cores | |
function onlinelittle() { | |
for i in $(seq 0 $((littlecluster - 1))); do | |
chmod 777 /sys/devices/system/cpu/cpu$i/online | |
echo 1 > /sys/devices/system/cpu/cpu$i/online | |
done | |
} | |
# Lock big cores to the passed through frequency | |
function lockbig() { | |
for i in $(seq $((coreno - bigcluster)) $((coreno - 1))); do | |
echo $1 > /sys/devices/system/cpu/cpu$i/cpufreq/scaling_max_freq | |
echo $1 > /sys/devices/system/cpu/cpu$i/cpufreq/scaling_min_freq | |
done | |
} | |
# Lock little cores to the passed through frequency | |
function locklittle () { | |
for i in $(seq 0 $((littlecluster - 1))); do | |
echo $1 > /sys/devices/system/cpu/cpu$i/cpufreq/scaling_max_freq | |
echo $1 > /sys/devices/system/cpu/cpu$i/cpufreq/scaling_min_freq | |
done | |
} | |
# Run dhrystone 3x - this assumes you have the binary in /data. | |
function rundhry() { | |
for i in $(seq 0 2); do | |
./dhrystone -l 100 | grep dhrystones | |
sleep 1 | |
done | |
} | |
echo "" | |
echo "" | |
echo "dhrystones/frequency benchmark by @nysascape" | |
echo "" | |
echo "" | |
echo "Setting all cores online..." | |
onlinebig | |
onlinelittle | |
echo "Stopping Android and other processes..." | |
stopserv | |
echo "Setting big cores offline..." | |
echo "" | |
offlinebig | |
# Test all little cluster frequencies | |
range=${#lcfreqs[@]} | |
for i in $(seq 0 $((range - 1))); do | |
locklittle ${lcfreqs[$i]} | |
freq=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq) | |
echo "Testing little cluster @ $freq" | |
rundhry | |
echo "" | |
done | |
echo "Setting big cores online..." | |
echo "" | |
onlinebig | |
echo "Setting little cores offline..." | |
echo "" | |
offlinelittle | |
# Test all big cluster frequencies | |
range=${#bcfreqs[@]}; | |
for i in $(seq 0 $((range - 1))); do | |
lockbig ${bcfreqs[$i]} | |
freq=$(cat /sys/devices/system/cpu/cpu$((coreno - 1))/cpufreq/scaling_min_freq) | |
echo "Testing big cluster @ $freq" | |
rundhry | |
echo "" | |
done | |
echo "Test done! Setting all cores back online and booting up..." | |
echo "NOTE: You will need to set your frequencies yourself!" | |
onlinelittle | |
onlinebig | |
reboot | |
echo "Made by @nysascape" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment