Skip to content

Instantly share code, notes, and snippets.

@tedd4u
Created May 14, 2018 19:24
Show Gist options
  • Save tedd4u/5369eb89a5eb5dd0280c5741a7bac578 to your computer and use it in GitHub Desktop.
Save tedd4u/5369eb89a5eb5dd0280c5741a7bac578 to your computer and use it in GitHub Desktop.
Embarrassingly bad ApacheBench wrapper that tests from 1-16 concurrency and scrapes the most important data
echo "warming $server ..."
ab -q -k -n 16000 -c 8 "$1" &> /dev/null
sleep 2
echo "starting test"
echo "threads, requests, test duration, req/sec, avg svc time, p50 lat, p90 lat, p99 lat, max lat"
for i in `seq 1 16`
do
echo -n "$i "
let j=i\*3000
echo -n "$j "
ab -q -k -n "$j" -c "$i" "$1" | egrep '(Time taken)|(99%)|(50%)|(90%)|(longest request)|(Requests per)|(mean\))' 2> /dev/null | sed 's/[0-9 ]*%[ ]*\([0-9]*\).*/\1/' | sed 's/Requests per [a-z: ]*\([0-9]*\.[0-9]*\).*/\1/' | sed 's/Time per [a-z: ]*\([0-9]*\.[0-9]*\).*/\1/' | sed 's/Time taken [a-z: ]*\([0-9]*\.[0-9]*\).*/\1/' | sed 's/\([0-9% ]*\)(longest request)/\1/' | tr '\n' ' '
echo
done
echo "done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment