Skip to content

Instantly share code, notes, and snippets.

@luketheobscure
Created July 21, 2024 19:38
Show Gist options
  • Save luketheobscure/d52b5b779e4cd76a8e23d1d7fe919842 to your computer and use it in GitHub Desktop.
Save luketheobscure/d52b5b779e4cd76a8e23d1d7fe919842 to your computer and use it in GitHub Desktop.
Simple load testing
# Very simple load testing script. Will invoke a given url X number of times
# example usage: ./loadtest.sh 25 "http://localhost:3000/my-url"
max="$1"
date
echo "url: $2
rate: $max calls / second"
START=$(date +%s);
get () {
curl -s -v "$1" 2>&1 | tr '\r\n' '\\n' | awk -v date="$(date +'%r')" '{print $0"\n-----", date}' >> /tmp/perf-test.log
}
while true
do
echo $(($(date +%s) - START)) | awk '{print int($1/60)":"int($1%60)}'
sleep 1
for i in `seq 1 $max`
do
get $2 &
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment