The below script will be helpful when you have to analyze load time for bunch of resources which would be difficult to get done one by one in the browser.
Feel free to make your own changes.
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 | |
resources_file=$1 | |
no_of_calls=$2 | |
if [[ ! -f $resources_file ]]; then | |
echo "Invalid file $resources_file" | |
exit 1 | |
fi | |
if [[ ! $no_of_calls =~ ^[0-9]+$ ]]; then | |
no_of_calls=1 | |
fi | |
result_file="${resources_file}_result.csv" | |
echo "url_effective,http_code,http_connect,time_total,time_namelookup,time_connect,time_appconnect,time_pretransfer,time_redirect,time_starttransfer,size_download,size_header,size_request,speed_download,speed_upload,content_type,num_connects" > "$result_file" | |
index=0 | |
for uri in $(cat $resources_file) | |
do | |
for i in $(seq $no_of_calls) | |
do | |
echo -e "Processing $index\r\c" | |
curl -s -o /dev/null -w "%{url_effective},%{http_code},%{http_connect},%{time_total},%{time_namelookup},%{time_connect},%{time_appconnect},%{time_pretransfer},%{time_redirect},%{time_starttransfer},%{size_download},%{size_header},%{size_request},%{speed_download},%{speed_upload},%{content_type},%{num_connects}" $uri >> "$result_file" 2>&1 | |
echo -e "\r" >> "$result_file" 2>&1 | |
done | |
(( index = index + 1 )) | |
done | |
echo "Output written to $result_file" |