Skip to content

Instantly share code, notes, and snippets.

@tsmx
Created October 25, 2020 20:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsmx/d40bb7770786055603d1a175496f359f to your computer and use it in GitHub Desktop.
Save tsmx/d40bb7770786055603d1a175496f359f to your computer and use it in GitHub Desktop.
A simple automation script for Apache Benchmark with bearer token authentication. Running multiple scenarios of requests/concurrency.
#!/bin/bash
# set URL to test here
url=YOUR_URL_HERE
# set test iterations here: requests|concurrent
declare -a iterations=("1|1" "10|10" "100|20" "100|100" "1000|50" "1000|100")
# first argument is the bearer token
if [ -z "$1" ]
then
echo "No Bearer token supplied"
exit -1
fi
token=$1
function get_perf_stats {
echo "$1/$2"
ab -H "Authorization: Bearer $token" -n $1 -c $2 -d -S -q $url | grep "\[ms\] (mean)"
echo ""
}
for val in ${iterations[@]}; do
requests=$(echo $val | cut -d '|' -f 1)
concurrent=$(echo $val | cut -d '|' -f 2)
get_perf_stats $requests $concurrent
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment