#!/system/bin/sh # power-load-test.sh - put the X9R under a reproducible load while sampling the power picture. # # Load = screen brightness max + N CPU busy loops (+ whatever the app/scanner does concurrently). # Sampling = SARADC channels / thermals / CPU freq / whether the USB scanner is still enumerated. # The busy loops are killed at the end (never left running) and brightness is restored by the caller. # # usage: power-load-test.sh [seconds] [cpus] [outfile] SECS=${1:-120} CPUS=${2:-4} OUT=${3:-/data/local/tmp/pwr_load.txt} DEV=/sys/bus/iio/devices/iio:device0 PIDS="" i=0 while [ "$i" -lt "$CPUS" ]; do (while :; do :; done) & PIDS="$PIDS $!" i=$((i + 1)) done : > "$OUT" n=0 while [ "$n" -lt "$SECS" ]; do u=$(cat /proc/uptime); u=${u%% *} a0=$(cat $DEV/in_voltage0_raw 2>/dev/null) a1=$(cat $DEV/in_voltage1_raw 2>/dev/null) a2=$(cat $DEV/in_voltage2_raw 2>/dev/null) t0=$(cat /sys/class/thermal/thermal_zone0/temp 2>/dev/null) t1=$(cat /sys/class/thermal/thermal_zone1/temp 2>/dev/null) f0=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq 2>/dev/null) f3=$(cat /sys/devices/system/cpu/cpu3/cpufreq/scaling_cur_freq 2>/dev/null) gun=$(grep -c Newtologic /proc/bus/input/devices 2>/dev/null) echo "$u $a0 $a1 $a2 $t0 $t1 $f0 $f3 $gun" >> "$OUT" n=$((n + 1)) sleep 0.5 done for p in $PIDS; do kill -9 "$p" 2>/dev/null; done sleep 1 echo "done $SECS samples -> $OUT" echo "load pids killed:$PIDS"