Skip to content

Instantly share code, notes, and snippets.

@clrh
Created September 27, 2012 15:07
Show Gist options
  • Select an option

  • Save clrh/3794511 to your computer and use it in GitHub Desktop.

Select an option

Save clrh/3794511 to your computer and use it in GitHub Desktop.
Perf ab testing cronable
#!/bin/bash
# Geal: csv file for ab testing, just describe pages to call and tests to launch
# csv sample:
# Get date;Page;Test;Time per request;Total transferred;Requests per second
# 201209271713;http://drupac_test/;ab -n 1 -c 1;181.345;13866;5.13
# 201209271713;http://drupac_test/;ab -n 5 -c 2;240.892;69330;9.53
# 201209271713;http://drupac_test/test;ab -n 1 -c 1;156.220;14693;6.91
# 201209271713;http://drupac_test/test;ab -n 5 -c 2;205.237;73465;11.76
# 201209271713;http://drupac_test/;ab -n 1 -c 1;154.212;13866;6.37
# 201209271713;http://drupac_test/;ab -n 5 -c 2;256.130;69330;9.56
# 201209271713;http://drupac_test/test;ab -n 1 -c 1;204.876;14693;7.84
# 201209271713;http://drupac_test/test;ab -n 5 -c 2;178.065;73465;11.00
# temporary file
F1=/tmp/buf
# resulting file
F2=/var/lib/jenkins/data/abtesting_final.csv
# output dir
DIR2=/var/lib/jenkins/data/
PAGES=( 'http://drupacdev138-dev/' )
CMDS=( 'ab -n 100 -c 1 ' 'ab -n 500 -c 10 ')
size_pages=${#PAGES[@]}
size_cmds=${#CMDS[@]}
CURDATE=`date +%Y%m%d%H%M`
mkdir $DIR2/$CURDATE
for ((i=0;i<$size_pages;i++)); do
for ((j=0;j<$size_cmds;j++)); do
# DEBUG
#echo ${CMDS[${j}]} ${PAGES[${i}]}
echo $CURDATE > $F1
echo ";" >> $F1
echo ${PAGES[${i}]} >> $F1
echo ";" >> $F1
echo ${CMDS[${j}]} >> $F1
echo ";" >> $F1
CMD="${CMDS[${j}]} ${PAGES[${i}]}"
RES=$($CMD)
echo "$CMD -- $RES" > $DIR2/$CURDATE/${i}${j}
echo "$RES" | grep "\[ms\] (mean)" | sed 's/.* \([0-9]\+\.[0-9]\+\).*/\1/' >> $F1
echo ";" >> $F1
echo "$RES" | grep "Total transferred" | sed 's/.* \([0-9]\+\).*/\1/' >> $F1
echo ";" >> $F1
echo "$RES"| grep "Requests per second" | sed 's/.* \([0-9]\+\.[0-9]\+\).*/\1/' >> $F1
# take the buffer file, remove end of line and push in the final file
tr -d "\n" < $F1 >> $F2
echo "" >> $F2
done
done
echo "Get date;Page;Test;Time per request;Total transferred;Requests per second"
cat $F2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment