Last active
February 3, 2016 23:33
-
-
Save alexcreek/10696628 to your computer and use it in GitHub Desktop.
wrapper for weighttp
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 | |
REQUESTS=( 50 100 200 400 800 1600 3200 5000 ) | |
USERS=( 5 10 20 40 80 160 320 500 ) | |
LOG=/tmp/bench.log | |
REQ_LOG=/tmp/req.log | |
TIME_LOG=/tmp/time.log | |
WEBSERVER=[enter webserver IP] # used to remotely restart apache | |
# Argument checking | |
if [[ $# -ne 2 ]]; then | |
echo "Usage: bench.sh [URL] '[APACHE RESTART CMD]'" > /dev/stderr | |
exit | |
fi | |
run_benchmark() { | |
echo > $LOG | |
weighttp $1 >> $LOG | |
sleep 1 | |
} | |
echo > $REQ_LOG | |
echo > $TIME_LOG | |
for i in {1..3}; do | |
ssh root@$WEBSERVER -t "$2" # restarts apache | |
sleep 2 | |
echo -n "Round $i" | |
echo "Round $i" >> $TIME_LOG | |
echo "Round $i" >> $REQ_LOG | |
for x in {0..7}; do | |
run_benchmark " -k -n ${REQUESTS[$x]} -c ${USERS[$x]} -t 1 $1" | |
grep "Total time" $LOG | grep -Po "\.\d{3}|\d+\.\d{3}" >> $TIME_LOG | |
grep "Requests per sec" $LOG | grep -Po "\d+" >> $REQ_LOG | |
echo -n "." | |
done | |
echo "Done" | |
# Don't bother waiting after the 3rd round | |
if [ $i -ne 3 ]; then | |
sleep 30 | |
fi | |
done | |
cat $REQ_LOG $TIME_LOG |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment