Skip to content

Instantly share code, notes, and snippets.

@Lewiscowles1986
Created February 13, 2018 12:45
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 Lewiscowles1986/6a2aeca4fa67bbfa4776ae4ce4e491bb to your computer and use it in GitHub Desktop.
Save Lewiscowles1986/6a2aeca4fa67bbfa4776ae4ce4e491bb to your computer and use it in GitHub Desktop.
Benchmark URL endpoint CSV
#!/bin/bash
if [[ $# -lt 1 ]];
then echo "You need to pass a url!"
echo "Usage:"
echo "$0 {url}"
exit
fi
URL=$1
for i in {1..1000}
do
#curl -s -o /dev/null -w "%{time_total}\n" $URL
curl -s -o /dev/null -w "%{time_total}\n" -H "Pragma: no-cache" $URL
done | awk '{ sum += $1; n++; print ","$1; } END { if(n > 0) print "average,=sum(B1:B"n")/count(B1:B"n")"; print "median,=median(B1:B"n")"; print "mode,=mode(B1:B"n")"; print "max,=max(B1:B"n")"; print "min,=min(B1:B"n")"; }'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment