Created
January 20, 2011 15:43
-
-
Save bruntonspall/788067 to your computer and use it in GitHub Desktop.
How I run perf tests repeatably with records of what I did
This file contains 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 | |
#Set Defaults | |
requests=${requests:=10} | |
threads=${threads:=1} | |
url=${url:=http://testserver/} | |
while getopts "r:t:u:h" Option | |
do | |
case $Option in | |
r ) requests=$OPTARG;; | |
t ) threads=$OPTARG;; | |
u ) url=$OPTARG;; | |
h ) help=1;; | |
* ) echo "Unimplemented option chosen.";; | |
esac | |
done | |
shift $(($OPTIND - 1)) | |
if [ ${help:-0} -eq 1 ]; then | |
echo "Test Runner" | |
echo "" | |
echo "-r num Number of Requests" | |
echo "-t num Number of Threads" | |
echo "-u url Url to test" | |
echo "" | |
exit 1 | |
fi | |
run=$(cat lastrun.txt) | |
((run+=1)) | |
echo -n "Run Description: " | |
read description | |
mkdir $run | |
echo "Starting test run: $run" | tee -a $run/settings.txt | |
echo "Date: $(date)" | tee -a $run/settings.txt | |
echo "Description: $description" | tee -a $run/settings.txt | |
echo "Parameters:" | tee -a $run/settings.txt | |
echo " Requests: $requests" | tee -a $run/settings.txt | |
echo " Threads: $threads" | tee -a $run/settings.txt | |
echo " Url: $url" | tee -a $run/settings.txt | |
echo "" | tee -a $run/settings.txt | |
ssh root@testserver "service squid stop; rm -Rf /var/spool/squid/*; service squid start" | |
ab -n $requests -c $threads -e $run/data.csv -g $run/data.gnuplot $url | tee $run/ablog.txt | |
echo $run > lastrun.txt | |
git add lastrun.txt | |
git add $run | |
git commit -m "Executed run $run" | |
git push |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Some nice features:
threads=20 ./runtest.sh
./runtest.sh -t 20
Please note that apachebench is useful for testing throughput and concurrency, but because it hits only a single url repeatedly it should be blazingly fast with a cache.
Also remember to re-initialise things inbetween tests, note that we restart squid between tests
Hope it helps someone