Skip to content

Instantly share code, notes, and snippets.

@stvhwrd
Created November 13, 2019 23:19
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 stvhwrd/7a70ff059d9047c3680b80d0a8f6b5a3 to your computer and use it in GitHub Desktop.
Save stvhwrd/7a70ff059d9047c3680b80d0a8f6b5a3 to your computer and use it in GitHub Desktop.
Submit CURL requests in a loop with rough RPS calculation
# Submit CURL requests in a loop with rough RPS calculation
run() {
num_requests=0;
start_time="$(date -u +%s)";
base_url="localhost/entities/"
while :; do
endpoint={base_url}$(date +"%S")
echo "Sending request to ${endpoint}..."
curl -s -o /dev/null -w "Response: %{http_code}\n" ${endpoint}
((num_requests=num_requests+1))
elapsed_time="$(("$(date -u +%s)"-$start_time))"
echo
echo "Sent "${num_requests}" requests in "${elapsed_time}" seconds @ $(awk "BEGIN {print $num_requests/$elapsed_time}") requests per second."
echo
sleep 5;
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment