Created
October 9, 2012 21:34
-
-
Save JayWalker512/3861603 to your computer and use it in GitHub Desktop.
Laptop battery consumption test under simulated user load
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/bash | |
RUNTIME=1500 #number of seconds to run for | |
DELAY=7 #time to delay between starting/closing progs | |
OUTFILE=$1 #file to write results in | |
FIRSTPROG="gimp" | |
SECONDPROG="geany" | |
THIRDPROG="rhythmbox" | |
STARTTIME=$SECONDS | |
ELAPSEDTIME=$(($SECONDS - $STARTTIME)) | |
if [ -z $OUTFILE ]; then | |
echo "You need to supply a filename to save the test log in!" | |
exit 1 | |
fi | |
`rm $OUTFILE` | |
while [ $ELAPSEDTIME -le $RUNTIME ] | |
do | |
#record elapsed time and power data | |
ELAPSEDTIME=$(($SECONDS - $STARTTIME)) | |
echo "Elapsed time: " $ELAPSEDTIME " Date: " `date` >> $OUTFILE | |
echo `upower -i /org/freedesktop/UPower/devices/battery_BAT0| grep -E "energy:|energy-rate|percentage"` >> $OUTFILE | |
#now echo the above data in the terminal window | |
echo "Elapsed time: " $ELAPSEDTIME " Date: " `date` | |
echo `upower -i /org/freedesktop/UPower/devices/battery_BAT0| grep -E "energy:|energy-rate|percentage"` | |
`$FIRSTPROG`& | |
sleep $DELAY | |
pkill $FIRSTPROG | |
sleep $DELAY | |
`$SECONDPROG`& | |
sleep $DELAY | |
pkill $SECONDPROG | |
sleep $DELAY | |
`$THIRDPROG`& | |
sleep $DELAY | |
pkill $THIRDPROG | |
sleep $DELAY | |
#do some kind of file writing/copying here to use the disk more | |
`dd if=/dev/urandom of=/tmp/temprandom bs=4M count=1`& | |
sleep $DELAY | |
done | |
#clean up | |
`rm /tmp/temprandom` | |
echo "Finished! Seconds:" $SECONDS | |
#record final data | |
#record elapsed time and power data | |
ELAPSEDTIME=$(($SECONDS - $STARTTIME)) | |
echo "Test finished! Elapsed time: " $ELAPSEDTIME " Date: " `date` >> $OUTFILE | |
echo `upower -i /org/freedesktop/UPower/devices/battery_BAT0| grep -E "energy:|energy-rate|percentage"` >> $OUTFILE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment