34 lines
1.0 KiB
Bash
34 lines
1.0 KiB
Bash
#!/bin/bash
|
|
|
|
echo "🔄 使用真实存在的文件测试下载速度..."
|
|
echo "======================================"
|
|
|
|
# 使用确实存在的测试文件
|
|
TEST_FILES=(
|
|
"http://speedtest.ftp.otenet.gr/files/test1Mb.db" # 国际测速文件
|
|
"http://ipv4.download.thinkbroadband.com/1MB.zip" # 英国测速
|
|
"http://cachefly.cachefly.net/100mb.test" # 美国CDN
|
|
)
|
|
|
|
# 或者使用国内真实存在的文件
|
|
DOMESTIC_FILES=(
|
|
"http://mirrors.aliyun.com/ubuntu/ls-lR.gz"
|
|
"http://mirrors.ustc.edu.cn/ubuntu/ls-lR.gz"
|
|
"http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ls-lR.gz"
|
|
)
|
|
|
|
for url in "${DOMESTIC_FILES[@]}"; do
|
|
domain=$(echo "$url" | awk -F/ '{print $3}')
|
|
echo "测试 $domain ..."
|
|
|
|
# 下载5秒并计算平均速度
|
|
speed=$(timeout 5 curl -L "$url" -o /dev/null --progress-bar -w "%{speed_download}" 2>/dev/null | awk '{printf "%.0f", $1/1024}')
|
|
|
|
if [[ $speed && $speed -gt 0 ]]; then
|
|
echo "✅ 下载速度: $speed KB/s"
|
|
else
|
|
echo "❌ 测试失败"
|
|
fi
|
|
echo "---"
|
|
done
|