This commit is contained in:
qiaofeng1227 2023-05-25 17:55:18 +08:00
parent 76f952e1c5
commit 0d43e8832d

View File

@ -311,16 +311,9 @@ function fastest_url() {
fastest_time=0 fastest_time=0
for url in "${urls[@]}"; do for url in "${urls[@]}"; do
total_time=0
for i in {1..5}; do
time=$(curl -s -w '%{time_total}\n' -o /dev/null $url) time=$(curl -s -w '%{time_total}\n' -o /dev/null $url)
total_time=$(echo "$total_time + $time" | bc -l) if (( $(echo "$time < $fastest_time || $fastest_time == 0" | bc -l) )); then
done fastest_time=$time
avg_time=$(echo "$total_time / 5" | bc -l)
if (( $(echo "$avg_time < $fastest_time || $fastest_time == 0" | bc -l) )); then
fastest_time=$avg_time
fastest_url=$url fastest_url=$url
fi fi
done done