Created
November 13, 2019 23:19
-
-
Save stvhwrd/7a70ff059d9047c3680b80d0a8f6b5a3 to your computer and use it in GitHub Desktop.
Submit CURL requests in a loop with rough RPS calculation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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