ab-stats/ab.sh

48 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
RUNS="$1";
NAME="$2"
URL="$3"
if [[ $RUNS == "" || $NAME == "" || $URL == "" ]]; then
echo
echo " invocation:"
echo " $0 <runs> <name> <url>"
echo
echo " runs - number of runs of ab to perform"
echo " name - test name, to be used on the names of output files"
echo " url - url to test"
echo
echo " results are saved to:"
echo " ./results/<name>-<run>.csv"
echo " ./results/<name>-<run>.log"
echo
echo " you can use merge-data.py to merge data (duh) from all available cvs and log files"
echo " and get averages calculated automatically"
echo
exit 1
fi
REQUESTS=2000
CONCURRENCY=32
CSV="./results/${NAME}-<run>.csv"
LOG="./results/${NAME}-<run>.log"
mkdir './results' >/dev/null 2>&1
echo
echo "benchmarking $URL:"
echo " - name : $NAME"
echo " - runs : $RUNS"
echo " - reuqests : $REQUESTS"
echo " - concurrency : $CONCURRENCY"
echo " - output:"
echo " - CSV: $CSV"
echo " - LOG: $LOG"
echo " - running:"
for (( I=0; $I < $RUNS; I = $I + 1 )); do
echo " - run ${I}..."
ab -e "./results/${NAME}-${I}.csv" -n $REQUESTS -c $CONCURRENCY "$URL" 2>&1 >"./results/${NAME}-${I}.log" | sed -r -e 's/^C(.*)/ - c\1/' -e 's/^F(.*)/ - f\1/'
done
echo " - all done."