Files
dock/测速中文
2025-10-28 14:20:17 +08:00

26 lines
830 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
echo "🚀 一键网络测速(精确版)"
# 延迟测试 - 20次ping取平均值
echo "🔄 测试网络延迟..."
ping -c 20 8.8.8.8 | tail -1 | awk -F'/' '{print "网络延迟: " $4 " ms"}'
# 下载速度测试 - 使用 dd 命令持续测试10秒
echo "⬇️ 测试下载速度..."
# 创建测试URL使用不同CDN确保稳定性
test_urls=(
"http://cachefly.cachefly.net/100mb.test"
"http://speedtest.ftp.otenet.gr/files/test100Mb.db"
"http://proof.ovh.net/files/100Mb.dat"
)
for url in "${test_urls[@]}"; do
echo "正在从 $(echo $url | cut -d'/' -f3) 测试..."
speed=$(curl -s -w "%{speed_download}" -o /dev/null --max-time 10 "$url")
speed_mbps=$(echo "scale=2; $speed / 1024 / 1024" | bc)
echo "下载速度: $speed_mbps MB/s"
break
done
echo "✅ 测速完成"