Last active
September 19, 2019 14:35
-
-
Save Jlaird/cd4b9cc41d6f33f0b38780bd26bc2f2e to your computer and use it in GitHub Desktop.
This file contains 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
#!/bin/bash | |
set -o errexit | |
main () { | |
local url=$1 | |
if [[ -z "$url" ]]; then | |
echo "ERROR: | |
An URL must be provided. | |
Example ./curl_speed_test.sh https://www.dentistryiq.com | |
Aborting. | |
" | |
exit 1 | |
fi | |
print_header | |
for i in `seq 1 100`; do | |
make_request $url | |
done | |
} | |
# headers | |
print_header () { | |
echo "code,time_total,time_connect,time_appconnect,time_starttransfer" | |
} | |
# Make request | |
make_request () { | |
local url=$1 | |
curl \ | |
--write-out "%{http_code},%{time_total},%{time_connect},%{time_appconnect},%{time_starttransfer}\n" \ | |
--silent \ | |
--output /dev/null \ | |
"$url" | |
} | |
main "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment