Skip to content
Snippets Groups Projects
Commit e1d9212c authored by Jonas Höppner's avatar Jonas Höppner Committed by Jonas Höppner
Browse files

scripts: Add gpu_load.sh script

The script converts the times in /sys/kernel/debug/gc/idle
into percent values over some time.
Tested on mx8mp.

PBB-46
parent e6d551b1
No related branches found
No related tags found
1 merge request!284scripts: Add gpu_load.sh script
#!/bin/bash
sleeptime="${1-1000}"
sleeptime_us="$(( sleeptime * 1000 ))"
gpuidle="$(cat /sys/kernel/debug/gc/idle)"
newline="
"
OLD_IFS="$IFS"
decode_sysfs(){
prefix="$1"
content="$2"
IFS="$newline"
for line in ${content}
do
type="${line%:*}"
timestamp="${line#*:}"
timestamp="${timestamp% ns}"
timestamp="${timestamp//,/}"
timestamp="${timestamp// /}"
eval "${prefix}_${type}=${timestamp}"
done
}
function report_load(){
decode_sysfs "start" "$gpuidle_prev"
decode_sysfs "stop" "$gpuidle"
on="$(( stop_On - start_On ))"
off="$(( stop_Off - start_Off ))"
idle="$(( stop_Idle - start_Idle ))"
susp="$(( stop_Suspend - start_Suspend ))"
total="$(( on + off + idle + susp ))"
#total="$(( sleeptime_us * 1000 ))"
on_p="$(( on * 10000 / total ))"
off_p="$(( off * 10000 / total ))"
idle_p="$(( idle * 10000 / total ))"
susp_p="$(( susp * 10000 / total ))"
total_p="$(( on_p + off_p + idle_p + susp_p ))"
# printf "$sleeptime ms: On %.1f%% Off %.1f%% Idle %.1f%% Susp %.1f%% Total %.1f%%\n" \
# "$(( on_p / 100 )).$(( on_p % 100 ))" \
# "$(( off_p / 100 )).$(( off_p % 100 ))" \
# "$(( idle_p / 100 )).$(( idle_p % 100 ))" \
# "$(( susp_p / 100 )).$(( susp_p % 100 ))" \
# "$(( total_p / 100 )).$(( total_p % 100 ))"
printf "$sleeptime ms: On %.1f%% Off %.1f%% Idle %.1f%% \r" \
"$(( on_p / 100 )).$(( on_p % 100 ))" \
"$(( off_p / 100 )).$(( off_p % 100 ))" \
"$(( idle_p / 100 )).$(( idle_p % 100 ))"
}
while true;
do
gpuidle_prev="$gpuidle"
usleep "$sleeptime_us"
gpuidle="$(cat /sys/kernel/debug/gc/idle)"
report_load
done
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment