fasturl improve

This commit is contained in:
qiaofeng1227 2023-06-09 17:44:38 +08:00
parent c5edc4254d
commit 1d81684850
2 changed files with 13 additions and 1 deletions

View file

@ -322,6 +322,12 @@ function fastest_url() {
fastest_time=0
for url in "${urls[@]}"; do
if curl --output /dev/null --silent --head --fail "$url"; then
echo $url" is available"
else
echo $url" is not available"
continue
fi
time=$(curl --connect-timeout 3 -s -w '%{time_total}\n' -o /dev/null $url)
if (( $(echo "$time < $fastest_time || $fastest_time == 0" | bc -l) )); then
fastest_time=$time

View file

@ -77,7 +77,13 @@ function fastest_url() {
fastest_time=0
for url in "${urls[@]}"; do
time=$(curl -s -w '%{time_total}\n' -o /dev/null $url)
if curl --output /dev/null --silent --head --fail "$url"; then
echo $url" is available"
else
echo $url" is not available"
continue
fi
time=$(curl --connect-timeout 3 -s -w '%{time_total}\n' -o /dev/null $url)
if (( $(echo "$time < $fastest_time || $fastest_time == 0" | bc -l) )); then
fastest_time=$time
fastest_url=$url