View Single Post
Posts: 171 | Thanked: 114 times | Joined on Feb 2010
#2547
Here is a script that I hacked together from the original script by rooted to measure the actual time that the CPU is running, including idle mode.

Code:
#!/bin/sh
awk '{print "\nCurrent frequency: "$1/1000" MHz\n"}' /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq
awk '{print "Minimum frequency: "$1/1000" MHz\n"}' /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
awk '{print "Maximum frequency: "$1/1000" MHz\n"}' /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq

tis1=`awk '{SUM += $2} END {printf("%.0f",SUM/1000)}' /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state`
idle0=`awk '{printf ("%.0f",$1/1000)}' /sys/devices/system/cpu/cpu0/cpuidle/state0/time`
idle1=`awk '{printf ("%.0f",$1/1000)}' /sys/devices/system/cpu/cpu0/cpuidle/state1/time`
idle2=`awk '{printf ("%.0f",$1/1000)}' /sys/devices/system/cpu/cpu0/cpuidle/state2/time`
idle3=`awk '{printf ("%.0f",$1/1000)}' /sys/devices/system/cpu/cpu0/cpuidle/state3/time`
totaltime=$(($idle0+$idle1+$idle2+$idle3+$tis1))
echo -e "FREQUENCY\tUSED"
awk '{printf (($1/1000)" MHz \t")};{if ($2 == 0) printf "0 %\n"; else printf ("%.3f %\n",($2/10)/"'"$totaltime"'")}' /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state
echo ""