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

25 lines
728 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 "🚀 一键网络测速(稳定版)"
# 延迟测试
echo "1. 网络延迟测试10次"
ping -c 10 114.114.114.114 | tail -1 | awk -F'/' '{print " 平均延迟: "$4" ms"}'
# 下载速度测试确保测试10秒
echo "2. 下载速度测试10秒"
for i in {1..3}; do
echo "$i次测试..."
start=$(date +%s)
speed=$(curl -s -w "%{speed_download}" -o /dev/null --max-time 10 http://cachefly.cachefly.net/100mb.test)
end=$(date +%s)
duration=$((end - start))
if [ $duration -ge 5 ]; then
speed_mbps=$(echo "scale=2; $speed / 1024 / 1024" | bc)
echo " 下载速度: $speed_mbps MB/s"
break
fi
done
echo "✅ 测速完成"